How to get last insert id safely?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
How to get last insert id safely in php with persistent connection to 
mysql?because there may be larger concurrence requests to the php to query 
insert statements.Example,the php query following two sql statements:

mysql_query("insert into tb(id,name) values(null,$username)");
$res = mysql_query("select last_insert_id()");

And in any time,user A insert one row to the table tb,and the same time 
before user A query last_insert_id(),user B insert another row to the same 
table too.
In this situation,will user A or B query last_insert_id() function get the 
correct id for he/her just insert?

Any ideas?Thanks!

Regards
Jacky 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux