RE: [PHP-DB] PHP/MySQL: Auto Increment
| From: | Lars Wilhelmsen | Date: | Mon, 21 Aug 2000 09:48:36 +0000 |
| Subject: | RE: [PHP-DB] PHP/MySQL: Auto Increment | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2203@lists.php.net to get a copy of this message | ||
If you want to control the last inserted ID, you could use
mysql_insert_id( $query_id )
which always return the last ID for the last inserted/updated row.
Regards,
-larsw-
--
Lars Wilhelmsen <lw@ez.no>, developer @ eZ systems <www.ez.no>
-----Original Message-----
From: Beau Hartshorne [mailto:beauh@home.com]
Sent: 17. august 2000 03:57
To: PHP
Subject: [PHP-DB] PHP/MySQL: Auto Increment
Hi,
I am creating a simple database to store course information. Each course is
to have a unique primary key. I generate this key using the auto increment
feature in MySQL. When I create a table, and add a bunch of rows, I get
something like this:
ID
--
1
2
3
4
Once I delete a few rows, the database might look like this.
ID
--
1
4
And after I add a few more, it may look like this:
ID
--
1
4
5
6
So, after a while the ID field has numbers that go all over the place. To
get around this problem, I run a php routine that resets all of the primary
key ids from 1 to whatever. I am worried that if there is more than one user
accessing the database, the data could get mixed up.
Is there a better way to keep this organized?
Thank you,
Beau
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net