note 86591 added to pdo.lastinsertid
| From: | espenunderscoregatmaildotcom at osu1 dot php dot net | Date: | Sat, 25 Oct 2008 03:08:56 +0000 |
| Subject: | note 86591 added to pdo.lastinsertid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145731@lists.php.net to get a copy of this message | ||
A better way of doing this in PostgreSQL is using the RETURNING keyword for the INSERT query.
You can use this SQL with the query function, and save a database call:
INSERT INTO tbl_users (firstname, lastname) VALUES ('John', 'Doe') RETURNING
user_id;
This is also more accurate in an environment where more than one record might be inserted at the
time, or other connections might insert records into the same table.
----
Server IP: 117.104.160.194
Probable Submitter: 58.164.73.1
----
Manual Page -- http://www.php.net/manual/en/pdo.lastinsertid.php
Edit -- https://master.php.net/note/edit/86591
Del: integrated -- https://master.php.net/note/delete/86591/integrated
Del: useless -- https://master.php.net/note/delete/86591/useless
Del: bad code -- https://master.php.net/note/delete/86591/bad+code
Del: spam -- https://master.php.net/note/delete/86591/spam
Del: non-english -- https://master.php.net/note/delete/86591/non-english
Del: in docs -- https://master.php.net/note/delete/86591/in+docs
Del: other reasons-- https://master.php.net/note/delete/86591
Reject -- https://master.php.net/note/reject/86591
Search -- https://master.php.net/manage/user-notes.php