09.02.2019, 17:35
mysql_insert_id is deprecated. If your query is an INSERT, then you use cache_insert_id.
You don't have to worry about it. The MySQL documentation states that the native will return the last AUTO_INCREMENT value based on a per-connection basis:
It is impossible for two different connections to collide with each other, as all clients will be sitting in their own unique connection to the server.
Quote:
for example there are two tables or one table 2 users did an insert query at once... |
Quote:
The ID that was generated is maintained in the server on a per-connection basis. This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column by that client. This value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own. This behavior ensures that each client can retrieve its own ID without concern for the activity of other clients, and without the need for locks or transactions. |