I am wondering what the best solution is to get the last inserted id after mysql query?
I found the following solutions:
<?php function get_current_insert_id($table) { $q = "SELECT LAST_INSERT_ID() FROM $table"; return mysql_num_rows(mysql_query($q)) + 1; } ?>
or even with the mysql_insert_id php mysql_insert_id , but apparently this function will not work well with bigint (this is what I use for the ID field), and if there are a lot of consecutive sql queries, it can be unreliable.
Can someone provide a reliable and quick solution to solve this problem?
source share