At 7:07 AM +0100 2/13/10, Rene Veerman wrote:
Hi.
I'm looking for the most efficient way to insert several records and
retrieve the auto_increment values for the inserted rows, while
avoiding crippling concurrency problems caused by multiple php threads
doing this on the same table at potentially the same time.
-snip-
Any clues are greatly appreciated..
I'm looking for the most sql server independent way to do this.
Rene:
I'm not sure what would be the most efficient way to solve the race
problems presented here, but you might want to not confront the race
problem at all and solve this a bit more straight forward -- for
example:
Three steps for each record:
1. Generate a unique value (i.e., date/time).
2. Insert the record with the unique value in a field and the
auto_increment ID will be automatically created.
3. Then search for the record with that unique value and retrieve the
auto_incremented ID value.
While this might take a few more cycles, it would work.
If you want your auto_increment ID's to be in sequence, then that's a
different problem and if so, maybe you should rethink the problem.
I've never seen a problem where the ID's were required to be anything
other than unique.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php