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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -