👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

With CodeIgniter 3, how to get the ID of the last inserted row in a table ?

With CodeIgniter 3, the method $this->db->insert_id() returns the ID of the last row inserted in a DB table.

// Insert $data in myTable (create a new row)
$this->db->insert('myTable', $data);

// Get the ID of the new row
$id = $this->db->insert_id();