RE: [PHP] RE: non-auto increment question
| From: | Jerry Schwartz | Date: | Thu, 26 Feb 2009 01:53:34 +0000 |
| Subject: | RE: [PHP] RE: non-auto increment question | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288803@lists.php.net to get a copy of this message | ||
>Being rather new to all this, I understood from the MySql manual that
>the auto_increment is to b e used immediately after an insertion not
>intermittently. My application is for administrators (the site owner &
>designates) to update the database from and administration directory,
>accessed by user/password login... so there's really very little
>possibility of 2 people accessing at the same time.
>By using MAX + 1 I keep the id number in the $idIn and can reuse it in
>other INSERTS
[JS] Are you looking for something like LAST_INSERT_ID()? If you INSERT a
record that has an auto-increment field, you can retrieve the value that got
inserted with "SELECT LAST_INSERT_ID()". It is connection-specific, so
you'll always have your "own" value. You can then save it to reuse, either
as a session variable or (more easily) as a hidden field on your form.
Regards,
Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032
860.674.8796 / FAX: 860.674.8341
www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com
>--
>
>Phil Jourdan --- pj@ptahhotep.com
>http://www.ptahhotep.com
>http://www.chiccantine.com
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:
>http://lists.mysql.com/mysql?unsub=jschwartz@the-
>infoshop.com