svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ update.xml

From: Date: Thu, 29 Dec 2011 14:59:50 +0000
Subject: svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ update.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9302@lists.php.net to get a copy of this message
derick Thu, 29 Dec 2011 14:59:50 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=321511 Log: Layout and rename newobj to new_object. Changed paths: U phpdoc/en/trunk/reference/mongo/mongocollection/update.xml Modified: phpdoc/en/trunk/reference/mongo/mongocollection/update.xml =================================================================== --- phpdoc/en/trunk/reference/mongo/mongocollection/update.xml 2011-12-29 14:57:37 UTC (rev 321510) +++ phpdoc/en/trunk/reference/mongo/mongocollection/update.xml 2011-12-29 14:59:50 UTC (rev 321511) @@ -12,7 +12,7 @@ <methodsynopsis> <modifier>public</modifier> <type>bool|array</type><methodname>MongoCollection::update</methodname> <methodparam><type>array</type><parameter>criteria</parameter></methodparam> - <methodparam><type>array</type><parameter>newobj</parameter></methodparam> + <methodparam><type>array</type><parameter>new_object</parameter></methodparam> <methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>array()</initializer></methodparam> </methodsynopsis> </refsect1> @@ -33,7 +33,7 @@ </varlistentry> <varlistentry> <term> - <parameter>newobj</parameter> + <parameter>new_object</parameter> </term> <listitem> <para> @@ -56,8 +56,9 @@ <literal>"upsert"</literal> </para> <para> - If no document matches $criteria, a new document will be created from - $criteria and $newobj (see upsert example below). + If no document matches <parameter>$criteria</parameter>, a new + document will be created from <parameter>$criteria</parameter> and + <parameter>$new_object</parameter> (see upsert example below). </para> </listitem> <listitem> @@ -294,17 +295,22 @@ ]]> </screen> <para> - If <literal>newobj</literal> 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 <parameter>$new_object</parameter> 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. </para> <programlisting role="php"> <![CDATA[ <?php -$c->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 @@ <title><function>MongoCollection::update</function> multiple example</title> <para> By default, <function>MongoCollection::update</function> 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 <parameter>$criteria</parameter> that it + finds. Using the "multiple" option can override this behavior, if needed. </para> <para> This example adds a "gift" field to every person whose birthday is in the @@ -341,7 +347,11 @@ <?php $today = array('$gt' => 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) +); ?> ]]>

« previous php.doc.cvs (#9302) next »