RE: [PHP] Auto-increment value
| From: | Jon Haworth | Date: | Wed, 18 Sep 2002 12:27:56 +0000 |
| Subject: | RE: [PHP] Auto-increment value | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-116731@lists.php.net to get a copy of this message | ||
Hi Bob,
> SELECT idno ORDER BY idno DESC LIMIT 1;
> assuming idno is what gets auto incremented
That's not the best idea - what happens if two users are inserting records
into the table at nearly-but-not-quite the same time?
1. Insert A goes through
2. Insert B goes through
3. LastID A returns the ID of B
4. LastID B returns the ID of B
Whoever did insert A would receive the wrong ID.
Cheers
Jon