note 114505 added to mongo.tutorial.insert
| From: | fabian at fabfuel dot de | Date: | Sat, 01 Mar 2014 06:21:41 +0000 |
| Subject: | note 114505 added to mongo.tutorial.insert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198750@lists.php.net to get a copy of this message | ||
If you do not specify a custom _id, the driver automatically pushes the generated _id to the given
document.
After saving, you can directly access the created _id:
<?php
...
$collection->insert($doc);
var_dump($doc['_id'])
// example output
object(MongoId)#8 (1) {
["$id"]=>
string(24) "4e2995576803fab768000000"
}
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/mongo.tutorial.insert.php
Edit -- https://master.php.net/note/edit/114505
Del: integrated -- https://master.php.net/note/delete/114505/integrated
Del: useless -- https://master.php.net/note/delete/114505/useless
Del: bad code -- https://master.php.net/note/delete/114505/bad+code
Del: spam -- https://master.php.net/note/delete/114505/spam
Del: non-english -- https://master.php.net/note/delete/114505/non-english
Del: in docs -- https://master.php.net/note/delete/114505/in+docs
Del: other reasons-- https://master.php.net/note/delete/114505
Reject -- https://master.php.net/note/reject/114505
Search -- https://master.php.net/manage/user-notes.php