michaelsanford
Translator, Web Developer
I've got a PHP script that inserts data into selected fields of a MySQL database.
One of these fields is an INT AUTO_INCREMENT PRIMARY KEY, so I pass a null value to the table and it generates one for itself.
How can I most efficiently retrieve this dynamically generated value?
I'd like to display a confirmation page with this unique identifier. The only problem is that number is the only unique identifier in the table, so I can't be certain I'll get THAT record with a SELECT query with any (or for that matter all) of the information just submitted.
I'd really like to avoid using PHP to generate the number if I can. The reason: I'd have to use PHP to retrieve the highest (most recent) unique identifier, but in the time it takes to query the DB and augment the number, another instance of the script can do the same thing with the same value, and then I could have multiple instances of that identifier (or incomprehensible error messages to my non-savvy users).
Any brilliant ideas?
One of these fields is an INT AUTO_INCREMENT PRIMARY KEY, so I pass a null value to the table and it generates one for itself.
How can I most efficiently retrieve this dynamically generated value?
I'd like to display a confirmation page with this unique identifier. The only problem is that number is the only unique identifier in the table, so I can't be certain I'll get THAT record with a SELECT query with any (or for that matter all) of the information just submitted.
I'd really like to avoid using PHP to generate the number if I can. The reason: I'd have to use PHP to retrieve the highest (most recent) unique identifier, but in the time it takes to query the DB and augment the number, another instance of the script can do the same thing with the same value, and then I could have multiple instances of that identifier (or incomprehensible error messages to my non-savvy users).
Any brilliant ideas?