note 109870 added to mongocollection.insert

From: Date: Wed, 29 Aug 2012 16:30:03 +0000
Subject: note 109870 added to mongocollection.insert
Groups: php.notes 
Request: Send a blank email to php-notes+get-190262@lists.php.net to get a copy of this message
If your unfortunate enough and got a task to change behavior of some MongoCollection methods you might encounter some weird behavior. For example this method will not work as expected and $a won't get _id field assigned: <?php namespace ns; class MongoCollection extends \MongoCollection { function insert(array &$a, array $options = []) { $res = parent::insert($a, $options); return $res; } } ?> a possible fix: <?php namespace ns; class MongoCollection extends \MongoCollection { function insert(array &$a, array $options = []) { $b = $a; $res = parent::insert($b, $options); $a = $b; return $res; } } ---- Server IP: 69.147.83.197 Probable Submitter: 77.221.79.87 ---- Manual Page -- http://www.php.net/manual/en/mongocollection.insert.php Edit -- https://master.php.net/note/edit/109870 Del: integrated -- https://master.php.net/note/delete/109870/integrated Del: useless -- https://master.php.net/note/delete/109870/useless Del: bad code -- https://master.php.net/note/delete/109870/bad+code Del: spam -- https://master.php.net/note/delete/109870/spam Del: non-english -- https://master.php.net/note/delete/109870/non-english Del: in docs -- https://master.php.net/note/delete/109870/in+docs Del: other reasons-- https://master.php.net/note/delete/109870 Reject -- https://master.php.net/note/reject/109870 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190262) next »