note 95900 added to function.PDO-lastInsertId
| From: | kevinhowardeaton at gmail dot com | Date: | Wed, 27 Jan 2010 22:07:25 +0000 |
| Subject: | note 95900 added to function.PDO-lastInsertId | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165390@lists.php.net to get a copy of this message | ||
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
----
Server IP: 74.208.171.221
Probable Submitter: 71.233.86.216
----
Manual Page -- http://www.php.net/manual/en/function.PDO-lastInsertId.php
Edit -- https://master.php.net/note/edit/95900
Del: integrated -- https://master.php.net/note/delete/95900/integrated
Del: useless -- https://master.php.net/note/delete/95900/useless
Del: bad code -- https://master.php.net/note/delete/95900/bad+code
Del: spam -- https://master.php.net/note/delete/95900/spam
Del: non-english -- https://master.php.net/note/delete/95900/non-english
Del: in docs -- https://master.php.net/note/delete/95900/in+docs
Del: other reasons-- https://master.php.net/note/delete/95900
Reject -- https://master.php.net/note/reject/95900
Search -- https://master.php.net/manage/user-notes.php