Welcome Guest, Not a member yet? Register   Sign In
Easy SQL query
#5

[eluser]JoostV[/eluser]
You probably tried this already, but $this->db->insert_id() merely returns the id, so
a. you need to have inserted a record first, or $this->db->insert_id() will not return anything
b. you need to capture the insert id in order to be able to do anything with it.

Code:
// Insert a record
$this->db->insert('mytable', $data);

// Retrieve last inserted id
$id = $this->db->insert_id();

// Print the last inserted id to screen
var_dump($id);


Messages In This Thread
Easy SQL query - by El Forum - 06-05-2009, 01:51 PM
Easy SQL query - by El Forum - 06-05-2009, 01:54 PM
Easy SQL query - by El Forum - 06-05-2009, 02:17 PM
Easy SQL query - by El Forum - 06-05-2009, 02:31 PM
Easy SQL query - by El Forum - 06-05-2009, 04:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB