note 92207 added to mongocollection.insert
| From: | quintonparker at gmail dot com | Date: | Tue, 14 Jul 2009 14:41:10 +0000 |
| Subject: | note 92207 added to mongocollection.insert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158275@lists.php.net to get a copy of this message | ||
Worth noting that insert() accepts the array by reference
On successful insert the array is returned with the _id assigned by Mongo
$doc = array(
'key1' => 'yay',
'key2' => 'yipee',
);
therefore becomes:
$doc = array(
'key1' => 'yay',
'key2' => 'yipee',
'_id' => '4a5c9100fbecbc00503debc8'
);
Handy. Akin to mysql's SELECT LAST_INSERT_ID() without the hassle of having to send another
query :-)
----
Server IP: 69.147.83.197
Probable Submitter: 196.35.158.178
----
Manual Page -- http://www.php.net/manual/en/mongocollection.insert.php
Edit -- https://master.php.net/note/edit/92207
Del: integrated -- https://master.php.net/note/delete/92207/integrated
Del: useless -- https://master.php.net/note/delete/92207/useless
Del: bad code -- https://master.php.net/note/delete/92207/bad+code
Del: spam -- https://master.php.net/note/delete/92207/spam
Del: non-english -- https://master.php.net/note/delete/92207/non-english
Del: in docs -- https://master.php.net/note/delete/92207/in+docs
Del: other reasons-- https://master.php.net/note/delete/92207
Reject -- https://master.php.net/note/reject/92207
Search -- https://master.php.net/manage/user-notes.php