Question #169   Submitted by Answiki on 10/01/2020 at 07:51:57 AM UTC

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

Answer   Submitted by Answiki on 10/01/2020 at 07:55:36 AM UTC

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 Answiki on 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 Answiki 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.