note 110745 added to mongocollection.insert

From: Date: Fri, 30 Nov 2012 17:21:18 +0000
Subject: note 110745 added to mongocollection.insert
Groups: php.notes 
Request: Send a blank email to php-notes+get-192234@lists.php.net to get a copy of this message
Another rarity to keep in mind. Passing references has the same effect as passing a referenced object. Even if there's no different for PHP between those two, it's probably not evident. So, this code would not have the _id field added to $a: <?php $b = &$a; /* ... more code here ... */ $m = new MongoClient; $collection = $m->test->phpmanual; $a = array('x' => 12); $collection->insert($a); var_dump($a); // array(1) { ["x"]=> int(12) } ?> I've made the assignment above to show how this situation could happen, if you reassigned a var, for example. But it could be some normal referencing after giving $a its final value (but before calling insert), and the consequence would be the same: if a var is referenced, it won't get the _id appended. ---- Server IP: 69.147.83.199 Probable Submitter: 186.52.24.136 ---- Manual Page -- http://www.php.net/manual/en/mongocollection.insert.php Edit -- https://master.php.net/note/edit/110745 Del: integrated -- https://master.php.net/note/delete/110745/integrated Del: useless -- https://master.php.net/note/delete/110745/useless Del: bad code -- https://master.php.net/note/delete/110745/bad+code Del: spam -- https://master.php.net/note/delete/110745/spam Del: non-english -- https://master.php.net/note/delete/110745/non-english Del: in docs -- https://master.php.net/note/delete/110745/in+docs Del: other reasons-- https://master.php.net/note/delete/110745 Reject -- https://master.php.net/note/reject/110745 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192234) next »