note 95900 deleted from function.PDO-lastInsertId by danbrown

From: Date: Wed, 27 Jan 2010 22:09:34 +0000
Subject: note 95900 deleted from function.PDO-lastInsertId by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165391@lists.php.net to get a copy of this message
Note Submitter: kevinhowardeaton at gmail dot com ---- In response to the lastInsertId issue, the simple workaround on MySQL is to set the last insert id in the SQL. For example: INSERT INTO names (first_name, last_name, middle_name) VALUES (?,?,?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id) In this case, the $conn->lastInsertId() function will return the last inserted ID. See the MySQL documentation at http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

« previous php.notes (#165391) next »