mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Layout and rename newobj to new_object.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@321511 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
255568b4c9
commit
61bc4ac8fe
1 changed files with 23 additions and 13 deletions
|
@ -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 @@ array(3) {
|
|||
]]>
|
||||
</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 @@ array(3) {
|
|||
<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 @@ array(3) {
|
|||
<?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)
|
||||
);
|
||||
|
||||
?>
|
||||
]]>
|
||||
|
|
Loading…
Reference in a new issue