Database Operations

Last Updated: September 6, 2021

You may need to follow database-related code when you develop plugins for WordPress

How to get the last inserted id of the table?

You can use the following code straight after the $wpdb->insert() 

$lastid = $wpdb->insert_id;

Make sure you have the primary key, auto-increment, unique for the id column