In a high concurrency environment, how to write a record to MySQL5.5 with PHP and how to return the id? of the record just inserted

in a high concurrency environment, how to write a record to MySQL5.5 with PHP and how to return the id? of the record just inserted

High concurrency
High concurrency
High concurrency

how to return the id? of the record currently inserted
MySQL version is 5.5


High concurrency cases should not be written directly to the database, but should first generate a unique hash value for the data, and then write to the cache. At the same time, the hash value is returned to the client.

then write the cached data to the database asynchronously.

it can be solved by looking up the database with a hash value.


SELECT LAST_INSERT_ID();

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.


mysql_insert_id () , which is also available in high concurrency.


mysqli:mysqli_insert_id ()
mysql:mysql_insert_id ()

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45dc2-44b77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45dc2-44b77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?