PHP/MySQL: Auto Increment
| From: | Beau Hartshorne | Date: | Thu, 17 Aug 2000 01:56:43 +0000 |
| Subject: | PHP/MySQL: Auto Increment | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2108@lists.php.net to get a copy of this message | ||
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