How reliable is mysql_insert_id()
in a competitive condition? I mean when multiple users are inserting data at the same time, will this function return the true ID or it will return other user's inserted data ID?
The table engine is MyISAM.
How reliable is mysql_insert_id()
in a competitive condition? I mean when multiple users are inserting data at the same time, will this function return the true ID or it will return other user's inserted data ID?
The table engine is MyISAM.
mysql_insert_id
is completely multi-user safe.It is entirely relies upon the database connection, and you can only have one user per connection....So, as per your question, it returns true id....From MySql documentation,
imho even when multiple users are inserting..it will be sequential in your program execution.
from php.net
"mysql_insert_id() acts on the last performed query, be sure to call mysql_insert_id() immediately after the query that generates the value. "
Also
Use of this extension is discouraged. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
You may also check this link from dev.mysql where it states that
"The value of mysql_insert_id() is affected only by statements issued within the current client connection. It is not affected by statements issued by other clients. "