Welcome Guest, Not a member yet? Register   Sign In
How does $this->db->insert_id() work exactly?
#1

[eluser]Mischievous[/eluser]
In the user guide it states that "$this->db->insert_id()" will return the insert ID number when performing database inserts.

but what does this pick up? the primary key with auto increment value? or do i have to pass it the field that i want to get from previous result?


Basically I'm trying to insert into a "user" table that has a sister table "user_profile" table... i need the user_id field (auto incremented, primary key) to use in the user_profile for the next insert?

Ideas, thoughts?

Code:
Code:
$this->db->insert('user', $user['user']);
$user['profile']['user_id'] = $this->db->insert_id();
$this->db->insert('user_profile', $user['profile']);


Messages In This Thread
How does $this->db->insert_id() work exactly? - by El Forum - 04-16-2010, 12:23 PM
How does $this->db->insert_id() work exactly? - by El Forum - 04-16-2010, 12:35 PM
How does $this->db->insert_id() work exactly? - by El Forum - 04-16-2010, 12:41 PM
How does $this->db->insert_id() work exactly? - by El Forum - 04-16-2010, 01:20 PM
How does $this->db->insert_id() work exactly? - by El Forum - 04-16-2010, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB