Welcome Guest, Not a member yet? Register   Sign In
Insert auto increment using insert_id
#1

[eluser]Ralanyo[/eluser]
I have searched to forums for this and the documentation and can't find an example if anyone can help, i'd appreciate it. Thanks

I just wrote a simple function that inserts into two tables fine but i'm having trouble with the insert_id(). Im trying to get the auto increment primary key of the salesperson table to insert into the salespersonid field of the company table. Here is my code, what am i doing wrong. Sorry for the newbie question

Code:
public function insertMore()
{
    $company = array(
    'companyname' => $this->input->post('company'),
    'salespersonid' => $this->db->insert_id()
       );
      
    $sales = array(
    'name' => $this->input->post('salesrep')
       );
      
       $id = array (
      
       );
    
       $results = array (
       $this->db->insert('company', $company),
       $this->db->insert('salesperson', $sales),
      
       );
      
       return $results;
}


Messages In This Thread
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:43 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:51 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 07:59 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:03 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:16 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:17 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:30 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:33 PM
Insert auto increment using insert_id - by El Forum - 08-11-2012, 08:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB