How to get last insert ID in Codeigniter

By | August 8, 2020
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:


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.

Leave a Reply

Your email address will not be published. Required fields are marked *