How to get last insert ID in Codeigniter

No comments
I assume, you must be creating a website where you are looking to get last insert id of executed INSERT query in parent table and then you want to store the last inserted ID in your child table as a foreign key.

In this post, i am going to share with you guys a small Codeigniter method that will help you to get last inserted id.

Here it is:
$this->db->insert_id();

Run this peace of code after insert query and this method will return you last inserted id of the executed query.

I hope this post will help.

No comments :

Post a Comment