Re: PHP/MySQL: Auto Increment

From: Date: Mon, 21 Aug 2000 10:14:57 +0000
Subject: Re: PHP/MySQL: Auto Increment
Groups: php.db 
Request: Send a blank email to php-db+get-2204@lists.php.net to get a copy of this message
This is the normal behaviour of the MySQL auto increment field, it only uses a number once. Generaly we don't associate this field to any kind of fisical attribute of the table, it's only the primary key, and you do not have to be worry about organization, the numbers will be created in a natural sequence, but deleted records ID number wont be generated anymore. I hope this helps. Jayme. www.conex.com.br/jjeffman -----Mensagem original----- De: Lars Wilhelmsen <lw@ez.no> Para: php-db@lists.php.net <php-db@lists.php.net> Data: Segunda-feira, 21 de Agosto de 2000 06:48 Assunto: RE: [PHP-DB] PHP/MySQL: Auto Increment >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 > > >-- >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 >

« previous php.db (#2204) next »