Skip to content

How to Get Last inserted ID in CodeIgnier?

We often need last inserted ID for different reasons(for example when you need to store foreign key), Immediately after a record has been inserted into the database, you can get the id that was auto incremented(primary Key).

Basic PHP MySQL Method



simply call CodeIgniter method

db->insert_id();?> 
?>

That’s it!

Reference URL: http://codeigniter.com/user_guide/database/helpers.html

0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments