Re: Add Record to DB and Return Auto_Increment ID?

From: Date: Sun, 21 Oct 2001 17:49:13 +0000
Subject: Re: Add Record to DB and Return Auto_Increment ID?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13579@lists.php.net to get a copy of this message
Do the insert missing out auto_increment column and then get it afterwoods with. $key = mysql_insert_id(); This actually is cleared on next database access, there is another function that is not (cant remember other function and I may of got them the wrong way round). If you are new to PHP you should look things up in the manual, there is a PDF and web searchable version for both MySQL and PHP. Search for AUTO_INCREMENT. Although I am impressed you are using db list not general one ;) Ben At 07:15 P 21/10/01, Brett Conrad wrote:
Hi. I'm creating a class mapped to the functions of a guestbook. Each guestbook submission becomes an entry in a db table. I am using the DB Pear class. I'm new to PHP and my question is this: What is the best way to create a method that adds a new guestbook entry and returns its auto_increment id. I could use an "Insert" statement and then a "Select" statement to find out what id was added for the record, but that seems a little inefficient. Any ideas? Thanks for any help. Much appreciated, Brett -- 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
**************************************************************
* Ben Edwards                                +352 091 429995 *
* Homepage                http://www.gifford.co.uk/~bedwards *
* i-Contact Progressive Video    http://www.videonetwork.org *
* Smashing the Corporate image     http://www.subvertise.org *
* Bristol's radical news            http://www.bristle.co.uk *
* PGP : F0CA 42B8 D56F 28AD 169B 49F3 3056 C6DB 8538 EEF8 * **************************************************************

« previous php.db (#13579) next »