php - how do i handle concurrent inserts in mysql table and fetch the correct insert id -


I'm using Adobe to the PHP library.

Use this function to bring the ID on which the record is inserted

 "$ db-> Insert_ID ()" 

I know If there are multiple and simultaneous inserts in the database table, then what method will this file be inserted to me to enter the ID?

The reason for this is that I use this last entry ID for the further processing of other records and I am making subsequent entries in the related table.

Is this approach quite safe or is I missing something?

Please help me in preparing a suitable work plan for this so that I can use the previous insert ID to be included in another table. Yes, it is safe for concurent use because it is because LAST_INSERT_ID ()

per-connection, as explained:

The ID that is generated is retained in the server on a per-connection basis. This means that the value given to the client given by the function is the first customer, which is the first AUTO_INCREMENT value generated for the most recent statement affecting that client's AUTO_INCREMENT column. This value can not be influenced by other clients, even if they generate their own AUTO_INCREMENT values, this behavior ensures that each customer can retrieve their ID without worrying for the other client's activity, and the locks Or without the need of the transaction.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -