From 61bc4ac8feaebab96ed9abcd0c26ad3d21961e5f Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 29 Dec 2011 14:59:50 +0000 Subject: [PATCH] Layout and rename newobj to new_object. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@321511 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongocollection/update.xml | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/reference/mongo/mongocollection/update.xml b/reference/mongo/mongocollection/update.xml index abf4344055..46be2cf253 100644 --- a/reference/mongo/mongocollection/update.xml +++ b/reference/mongo/mongocollection/update.xml @@ -12,7 +12,7 @@ public bool|arrayMongoCollection::update arraycriteria - arraynewobj + arraynew_object arrayoptionsarray() @@ -33,7 +33,7 @@ - newobj + new_object @@ -56,8 +56,9 @@ "upsert" - If no document matches $criteria, a new document will be created from - $criteria and $newobj (see upsert example below). + If no document matches $criteria, a new + document will be created from $criteria and + $new_object (see upsert example below). @@ -294,17 +295,22 @@ array(3) { ]]> - If newobj does not contain $-operators, an upsert will - create a new document from it alone. This matches the behavior of a normal - update, where not using $-operators causes the whole document to be - overwritten. + If $new_object does not contain $-operators, an upsert will + create a new document from the passed fields only. This matches the + behavior of a normal update, where not using $-operators causes the whole + document to be overwritten. update(array("name" => "joe"), array("username" => "joe312", "createdAt" => new MongoDate()), - array("upsert" => true)); +$c->drop(); +$c->update( + array("name" => "joe"), + array("username" => "joe312", "createdAt" => new MongoDate()), + array("upsert" => true) +); +var_dump($c->findOne()); ?> ]]> @@ -329,8 +335,8 @@ array(3) { <function>MongoCollection::update</function> multiple example By default, MongoCollection::update will only update - the first document matching $criteria that it finds. Using the "multiple" - option can override this behavior, if needed. + the first document matching $criteria that it + finds. Using the "multiple" option can override this behavior, if needed. This example adds a "gift" field to every person whose birthday is in the @@ -341,7 +347,11 @@ array(3) { new MongoDate(), '$lt' => new MongoDate(strtotime("+1 day"))); -$people->update(array("birthday" => $today), array('$set' => array('gift' => $surprise)), array("multiple" => true)); +$people->update( + array("birthday" => $today), + array('$set' => array('gift' => $surprise)), + array("multiple" => true) +); ?> ]]>