mysql - Last Auto increment ID before insert query in Wordpress -
i want last auto increment id in wordpress.so have tried last_insert_id();
$last_id = $wpdb->query('select last_insert_id();'); $new_id = $last_id + 1;
but not working , per official mysql site : give id of executed insert statement
any other way id? pl help.
$wpdb->query function returns integer value indicating number of rows affected/selected. create, alter, truncate , drop sql statements, function returns true on success.
use $wpdb->get_var function instead.
$last_id = $wpdb->get_var('select last_insert_id();'); $new_id = $last_id + 1;
Comments
Post a Comment