Suppose that in my system an user U1 create a new database entry in table A and I use lastInsertId function to get the ID (auto_increment field) of such entry, but almost at the same time (a little later) another user U2 do the same.
In this case, does lastInsertId return for U1 the ID of the entry added by the other user, since it is the most recent?
Thanks.
I believe you should only worry about race conditions in case your using a single connection for different threads. If your using a different connection for each request, you should be fine. Checkout http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With