note 109868 added to mongocollection.insert

From: Date: Wed, 29 Aug 2012 14:10:51 +0000
Subject: note 109868 added to mongocollection.insert
Groups: php.notes 
Request: Send a blank email to php-notes+get-190260@lists.php.net to get a copy of this message
Note, that the _id field will only be added to an inserted array if it does not already exist in the supplied array: $data = array('x' => 12); var_dump($data); $collection->insert($data); var_dump($data); Will output something like: array(1) { ["x"]=> int(12) } array(2) { ["x"]=> int(12) ["_id"]=> object(MongoId)#196 (1) { ["$id"]=> string(24) "503e21fc0605290912000000" } } however, $data = array('x' => 12, '_id' => NULL); var_dump($data); $collection->insert($data); var_dump($data); will not have the same result: array(2) { ["x"]=> int(12) ["_id"]=> NULL } array(2) { ["x"]=> int(12) ["_id"]=> NULL } ---- Server IP: 192.41.42.26 Probable Submitter: 70.180.196.17 ---- Manual Page -- http://www.php.net/manual/en/mongocollection.insert.php Edit -- https://master.php.net/note/edit/109868 Del: integrated -- https://master.php.net/note/delete/109868/integrated Del: useless -- https://master.php.net/note/delete/109868/useless Del: bad code -- https://master.php.net/note/delete/109868/bad+code Del: spam -- https://master.php.net/note/delete/109868/spam Del: non-english -- https://master.php.net/note/delete/109868/non-english Del: in docs -- https://master.php.net/note/delete/109868/in+docs Del: other reasons-- https://master.php.net/note/delete/109868 Reject -- https://master.php.net/note/reject/109868 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190260) next »