Forum Moderators: open
EX: An event table with a unique auto-increment ID and event details.
And a participants table where I want the same ID to be inserted so I can store event participants.
My question is whether or not this is a good way to go about this, and can LAST_INSERT_ID() get mixed up (will it ever pick up the wrong ID?) if the script that executes this PHP / MySQL is getting heavy traffic and being executed multiple times, at the same time.
This is just a concern I have, anyone know the answer?
Thanks,
The last ID that was generated is maintained in the server on a per-connection basis. This means the value the function returns to a given client is the most recent AUTO_INCREMENT value generated by that client. The value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own. This behavior ensures that you can retrieve your own ID without concern for the activity of other clients, and without the need for locks or transactions.