Pre-recorded question

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

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();


2 events in history
Answer by Alphonsio 10/01/2020 at 07:55:36 AM

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();


Question by Alphonsio 10/01/2020 at 07:51:57 AM
With CodeIgniter 3, how to get the ID of the last inserted row in a table ?
# ID Query URL Count

Icons proudly provided by Friconix.