Re: PHP/MySQL: Auto Increment
| From: | curt | Date: | Thu, 17 Aug 2000 03:30:27 +0000 |
| Subject: | Re: PHP/MySQL: Auto Increment | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2109@lists.php.net to get a copy of this message | ||
I'm not certain what you're after. Is it a way to preclude users from
accessing the tables while you're running your PHP routine? LOCK TABLES
will do it; check the MySQL manual.
I wonder, though, why you're doing the renumbering (though I sorta like
the neatness of it myself). If you want to sort them in order of
submission/creation/whatever you could use TIMESTAMP or one of its
variants. There're no performance gains to be had from row order; check
out this link from U. Texas-Austin on database normalization. The first
normal form addresses row ordering specifically.
http://www.gslis.utexas.edu/~l384k11w/normover.html
Hope this is useful.
cheers,
curt
Beau Hartshorne wrote:
>
> 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