How to get last inserted id in Codeigniter?

Sometimes, we require to get last insert record id from database in controller, so in this example we will learn how to get last inserted row id in Codeigniter 3 project. It’s very often need to get last insert id while working with Database ( in programming field), if you are working on Codeigniter PHP MVC framework and you want to fetch last created id (meaning max id). Codeigniter provides insert_id() mothod to get last inserted id. insert_id() is function of “db” library. DB library provides several functions for database related tasks. insert_id() will return id of last inserted record. insert_id() Controller Method

I hope it can help you…

Read More