Is it possible for mysqli_insert_id to return an incorrect id in high traffic applications?
No. mysqli_insert_id
returns the most the AUTO_INCREMENT
value from the most recent INSERT
query on the current connection. It will never get confused with another connection, for example.
No. How can I be so sure? Because it would have been reported and fixed a long time ago.
Quoting from a previous answer to this exact same question:
Look at http://dev.mysql.com/doc/refman/5.6/en/getting-unique-id.html for more information, it says this:
"For LAST_INSERT_ID(), the most recently generated ID is maintained in the server on a per-connection basis. It is not changed by another client. It is not even changed if you update another AUTO_INCREMENT column with a nonmagic value (that is, a value that is not NULL and not 0). Using LAST_INSERT_ID() and AUTO_INCREMENT columns simultaneously from multiple clients is perfectly valid. Each client will receive the last inserted ID for the last statement that client executed."
So you should be fine doing what you want and you shouldn't get strange results.