RE: [PHP-DB] Getting key of row just inserted into mySQL

From: Date: Wed, 22 Aug 2001 23:45:48 +0000
Subject: RE: [PHP-DB] Getting key of row just inserted into mySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11694@lists.php.net to get a copy of this message
This has been covered countless times on the list... :) http://www.php.net/manual/en/function.mysql-insert-id.php -----Original Message----- From: Grant Boggs [mailto:support@cornerstonesoftware.ws] Sent: Wednesday, August 22, 2001 7:24 PM To: php-db@lists.php.net Subject: [PHP-DB] Getting key of row just inserted into mySQL What's the best way to get the primary key of a row just inserted into a mySQL database? If the primary key is autoincrement, I insert a row. It's successful, but now how to do I read back the key of this table? Right now I'm adding a md5 hash of the session id into the row I'm inserting, and then will read that row back. But this seems clunky.... Should I just go for a "keytable" approach? Where I have a no autoincrement fields and just a table that holds the key value for each table. When I insert a row, I lock the row of the keytable I'm inserting int, update it's value, write it back, then use that key to insert into the main table? -- ================== Grant Boggs http://www.cornersonesoftware.ws -- 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 (#11694) next »