how to get last inserted id in codeigniter example

how to get last inserted id in codeigniter example

In this article, we will explain to you how to get the last inserted id in Codeigniter. we will give a simple example of how to retrieve the last insert id into Codeigniter.

When we had fetched the last inserted ID into PHP, we were used to last auto-increment id. but CodeIgniter has provided an insert query (active record style) used to fetch the last insert id.

In this example, we will take a simple example of how to fetch the last inserted id from the table in CodeIgniter. Generally, the insert_id() CodeIgniter function returns the last inserting id from the Mysql database. Sometimes, when you need to insert a record of one table to another table at that time use the insert_id function. We hope you can learn something from this post.

Please follow and like us: