note 110746 modified in mongocollection.save by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 Dec 2012 14:12:06 +0000 |
| Subject: | note 110746 modified in mongocollection.save by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192300@lists.php.net to get a copy of this message | ||
Same as with method insert(), it is worth noting that creating a reference to $obj will have the
same effect as $obj being a reference itself, i.e. no _id field will be added.
<?php
$a = &$obj;
$m = new MongoClient;
$collection = $m->test->phpmanual;
$obj = array('x' => 1);
// Suppose you create a reference for some reason
$a = &$obj;
$collection->save($obj);
var_dump($obj);
// prints: array(1) { ["x"]=> int(1) }
?>
--was--
Same as with method insert(), it is worth noting that creating a reference to $obj will have the
same effect as $obj being a reference itself, i.e. no _id field will be added.
<?php
$a = &$obj;
$m = new MongoClient;
$collection = $m->test->phpmanual;
$obj = array('x' => 1);
// Suppose you create a reference for some reason
$a = &$obj;
$collection->save($obj);
var_dump($obj);
// prints: array(1) { ["x"]=> int(1) }
http://php.net/manual/en/mongocollection.save.php