<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-bulkwrite.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-bulkwrite.update.php',
    1 => 'MongoDB\\Driver\\BulkWrite::update',
    2 => 'Add an update operation to the bulk',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-bulkwrite.php',
    1 => 'MongoDB\\Driver\\BulkWrite',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-bulkwrite.insert.php',
    1 => 'MongoDB\\Driver\\BulkWrite::insert',
  ),
  'next' => 
  array (
    0 => 'class.mongodb-driver-bulkwritecommand.php',
    1 => 'MongoDB\\Driver\\BulkWriteCommand',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/bulkwrite/update.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-bulkwrite.update" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\BulkWrite::update</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\BulkWrite::update</span> &mdash; <span class="dc-title">Add an update operation to the bulk</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-bulkwrite.update-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\BulkWrite::update</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$filter</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$newObj</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$updateOptions</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="simpara">
   Adds an update operation to the
   <span class="classname"><a href="class.mongodb-driver-bulkwrite.php" class="classname">MongoDB\Driver\BulkWrite</a></span>.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-bulkwrite.update-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
   
    <dt><code class="parameter">filter</code> (<span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span>)</dt>
    <dd>
     <p class="para">
      Das <a href="https://www.mongodb.com/docs/manual/tutorial/query-documents/" class="link external">&raquo;&nbsp;Abfrage-Prädikat</a>.
      Ein leeres Prädikat passt auf alle Dokumente in der Sammlung.
     </p>
     <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
      <span class="simpara">
       Bei der Auswertung von Abfragekriterien vergleicht MongoDB Typen und Werte gemäß seiner eigenen
       <a href="https://www.mongodb.com/docs/manual/reference/bson-type-comparison-order/" class="link external">&raquo;&nbsp;Vergleichsregeln für BSON-Typen</a>, die sich von PHPs Regeln für <a href="types.comparisons.php" class="link">Typenvergleich</a> und <a href="language.types.type-juggling.php" class="link">Typen-Jonglage</a> unterscheidet. Wenn es eine Übereinstimmung mit einem speziellen BSON-Typ gibt, sollten die Abfragekriterien die entsprechende <a href="mongodb.bson.php" class="link">BSON-Klasse</a> verwenden (z. B. <span class="classname"><a href="class.mongodb-bson-objectid.php" class="classname">MongoDB\BSON\ObjectId</a></span>, um auf eine <a href="https://www.mongodb.com/docs/manual/reference/bson-types/#objectid" class="link external">&raquo;&nbsp;ObjectId</a> zu passen).
      </span>
     </p></blockquote>
    </dd>
   

   
    <dt><code class="parameter">newObj</code> (<span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span>)</dt>
    <dd>
     <span class="simpara">
      A document containing either update operators (e.g.
      <code class="literal">$set</code>), a replacement document (i.e.
      <em>only</em> <code class="literal">field:value</code> expressions), or
      an <a href="https://www.mongodb.com/docs/manual/reference/command/update/#update-with-an-aggregation-pipeline" class="link external">&raquo;&nbsp;aggregation pipeline</a>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">updateOptions</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>updateOptions</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
          <th>Default</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>arrayFilters</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <span class="simpara">
            An array of filter documents that determines which array elements to
            modify for an update operation on an array field. See
            <a href="https://www.mongodb.com/docs/manual/reference/command/update/#update-command-arrayfilters" class="link external">&raquo;&nbsp;Specify arrayFilters for Array Update Operations</a>
            in the MongoDB manual for more information.
           </span>
           <span class="simpara">
            This option is available in MongoDB 3.6+ and will result in an
            exception at execution time if specified for an older server
            version.
           </span>
          </td>
         </tr>

         
         <tr>
          <td>collation</td>
          <td><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span></td>
          <td>
           <p class="para">
            Die <a href="https://www.mongodb.com/docs/upcoming/reference/collation/" class="link external">&raquo;&nbsp;Collation</a> (Vergleichs-/Sortierregel) ermöglicht es dem Benutzer, sprachspezifische Regeln für den Vergleich von Zeichenketten anzugeben, so z. B. Regeln für die Groß- und Kleinschreibung und Akzentzeichen. Bei der Angabe der Sortierung ist das Feld <code class="literal">&quot;locale&quot;</code> obligatorisch; alle anderen Sortierfelder sind optional. Die Beschreibungen der Felder sind unter <a href="https://www.mongodb.com/docs/upcoming/reference/collation/#collation-document" class="link external">&raquo;&nbsp;Collation Document</a> zu finden.
           </p>
           <p class="para">
            Wenn keine Kollation angegeben wurde, aber die Sammlung eine Standardkollation hat, verwendet die Operation die für die Sammlung angegebene Kollation. Wenn weder für die Sammlung noch für die Operation eine Kollation angegeben wurde, verwendet MongoDB den einfachen binären Vergleich, der in früheren Versionen für den Vergleich von Zeichenketten verwendet wurde.
           </p>
           <p class="para">
            Diese Option ist ab MongoDB 3.4 verfügbar. Wenn sie für eine ältere Serverversion angegeben wird, kommt es bei der Ausführung zu einer Exception.
           </p>
          </td>
         </tr>


         <tr>
          <td>hint</td>
          <td><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span></td>
          <td>
           <span class="simpara">
            Index specification. Specify either the index name as a string or
            the index key pattern. If specified, then the query system will only
            consider plans using the hinted index.
           </span>
           <span class="simpara">
            This option is available in MongoDB 4.2+ and will result in an
            exception at execution time if specified for an older server
            version.
           </span>
          </td>
         </tr>

         <tr>
          <td>multi</td>
          <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
          <td>
           Update only the first matching document if <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, or all
           matching documents <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>. This option cannot be <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if
           <code class="parameter">newObj</code> is a replacement document.
          </td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
         </tr>

         <tr>
          <td>sort</td>
          <td><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.object.php" class="type object">object</a></span></span></td>
          <td>
           <span class="simpara">
            Specify which document the operation updates if the query matches
            multiple documents. The first document matched by the sort order
            will be updated.
           </span>
           <span class="simpara">
            This option cannot be used if <code class="literal">&quot;multi&quot;</code> is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
           </span>
           <span class="simpara">
            This option is available in MongoDB 8.0+ and will result in an
            exception at execution time if specified for an older server
            version.
           </span>
          </td>
         </tr>

         <tr>
          <td>upsert</td>
          <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
          <td>
           If <code class="parameter">filter</code> does not match an existing document,
           insert a <em>single</em> document. The document will be
           created from <code class="parameter">newObj</code> if it is a replacement
           document (i.e. no update operators); otherwise, the operators in
           <code class="parameter">newObj</code> will be applied to
           <code class="parameter">filter</code> to create the new document.
          </td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-bulkwrite.update-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   Es wird kein Wert zurückgegeben.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-bulkwrite.update-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <ul class="simplelist">
   <li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>, wenn beim Analysieren von Argumenten ein Fehler auftritt.</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-bulkwrite.update-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL mongodb 1.21.0</td>
      <td>
       Added the <code class="literal">&quot;sort&quot;</code> option.
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.7.0</td>
      <td>
       Added the <code class="literal">&quot;hint&quot;</code> option.
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.6.0</td>
      <td>
       The <code class="parameter">newObj</code> parameter now accepts an aggregation
       pipeline. This feature requires MongoDB 4.2+ and will result in an
       exception at execution time if specified for an older server version.
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.5.0</td>
      <td>
       Using the <code class="literal">&quot;arrayFilters&quot;</code> option will result in an
       exception at execution time if unsupported by the server. Previously,
       no exception would be thrown and the option may have been ignored.
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.4.0</td>
      <td>
       Added the <code class="literal">&quot;arrayFilters&quot;</code> option.
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.2.0</td>
      <td>
       Added the <code class="literal">&quot;collation&quot;</code> option.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-mongodb-driver-bulkwrite.update-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 <span class="function"><strong>MongoDB\Driver\BulkWrite::update()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$bulk </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoDB\Driver\BulkWrite</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$bulk</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">update</span><span style="color: #007700">(<br />    [</span><span style="color: #DD0000">'x' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">2</span><span style="color: #007700">],<br />    [</span><span style="color: #DD0000">'$set' </span><span style="color: #007700">=&gt; [</span><span style="color: #DD0000">'y' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">3</span><span style="color: #007700">]],<br />    [</span><span style="color: #DD0000">'multi' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #DD0000">'upsert' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">false</span><span style="color: #007700">]<br />);<br /><br /></span><span style="color: #0000BB">$manager </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoDB\Driver\Manager</span><span style="color: #007700">(</span><span style="color: #DD0000">'mongodb://localhost:27017'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">$manager</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">executeBulkWrite</span><span style="color: #007700">(</span><span style="color: #DD0000">'db.collection'</span><span style="color: #007700">, </span><span style="color: #0000BB">$bulk</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-mongodb-driver-bulkwrite.update-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="mongodb-driver-manager.executebulkwrite.php" class="methodname" rel="rdfs-seeAlso">MongoDB\Driver\Manager::executeBulkWrite()</a> - Execute one or more write operations</span></li>
   <li><span class="classname"><a href="class.mongodb-driver-writeresult.php" class="classname">MongoDB\Driver\WriteResult</a></span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>