<?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-server.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-server.executebulkwrite.php',
    1 => 'MongoDB\\Driver\\Server::executeBulkWrite',
    2 => 'Execute one or more write operations on this server',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-server.php',
    1 => 'MongoDB\\Driver\\Server',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-server.construct.php',
    1 => 'MongoDB\\Driver\\Server::__construct',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-server.executebulkwritecommand.php',
    1 => 'MongoDB\\Driver\\Server::executeBulkWriteCommand',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/server/executebulkwrite.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-server.executebulkwrite" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Server::executeBulkWrite</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Server::executeBulkWrite</span> &mdash; <span class="dc-title">Execute one or more write operations on this server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-server.executebulkwrite-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Server::executeBulkWrite</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$namespace</code></span>, <span class="methodparam"><span class="type"><a href="class.mongodb-driver-bulkwrite.php" class="type MongoDB\Driver\BulkWrite">MongoDB\Driver\BulkWrite</a></span> <code class="parameter">$bulk</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">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="class.mongodb-driver-writeresult.php" class="type MongoDB\Driver\WriteResult">MongoDB\Driver\WriteResult</a></span></div>

  <p class="para rdfs-comment">
   Executes one or more write operations on this server.
  </p>
  <p class="para">
   A <span class="classname"><a href="class.mongodb-driver-bulkwrite.php" class="classname">MongoDB\Driver\BulkWrite</a></span> can be constructed with
   one or more write operations of varying types (e.g. updates, deletes, and
   inserts). The driver will attempt to send operations of the same type to the
   server in as few requests as possible to optimize round trips.
  </p>
  <p class="para">
   The default value for the <code class="literal">&quot;writeConcern&quot;</code> option will be
   inferred from an active transaction (indicated by the
   <code class="literal">&quot;session&quot;</code> option), followed by the
   <a href="mongodb-driver-manager.construct.php#mongodb-driver-manager.construct-uri" class="link">connection URI</a>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-server.executebulkwrite-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
   
    <dt><code class="parameter">namespace</code> (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)</dt>
    <dd>
     <p class="para">
      A fully qualified namespace (e.g. <code class="literal">&quot;databaseName.collectionName&quot;</code>).
     </p>
    </dd>
   

   
   
    <dt><code class="parameter">bulk</code> (<span class="classname"><a href="class.mongodb-driver-bulkwrite.php" class="classname">MongoDB\Driver\BulkWrite</a></span>)</dt>
    <dd>
     <p class="para">
      The write(s) to execute.
     </p>
    </dd>
   

   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>options</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         
         <tr>
          <td>session</td>
          <td><span class="classname"><a href="class.mongodb-driver-session.php" class="classname">MongoDB\Driver\Session</a></span></td>
          <td>
           <p class="para">
            A session to associate with the operation.
           </p>
          </td>
         </tr>


         
         <tr>
          <td>writeConcern</td>
          <td><span class="classname"><a href="class.mongodb-driver-writeconcern.php" class="classname">MongoDB\Driver\WriteConcern</a></span></td>
          <td>
           <p class="para">
            A write concern to apply to the operation.
           </p>
          </td>
         </tr>


        </tbody>
       
      </table>

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


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-server.executebulkwrite-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">Returns <span class="classname"><a href="class.mongodb-driver-writeresult.php" class="classname">MongoDB\Driver\WriteResult</a></span> on success.</p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-server.executebulkwrite-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <ul class="simplelist">
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> if <code class="parameter">bulk</code> does not contain any write operations.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> if <code class="parameter">bulk</code> has already been executed. <span class="classname"><a href="class.mongodb-driver-bulkwrite.php" class="classname">MongoDB\Driver\BulkWrite</a></span> objects may not be executed multiple times.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> if the <code class="literal">&quot;session&quot;</code> option is used in combination with an unacknowledged write concern.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li><li>Throws <span class="classname"><a href="class.mongodb-driver-exception-connectionexception.php" class="classname">MongoDB\Driver\Exception\ConnectionException</a></span> if connection to the server fails (for reasons other than authentication).</li><li>Throws <span class="classname"><a href="class.mongodb-driver-exception-authenticationexception.php" class="classname">MongoDB\Driver\Exception\AuthenticationException</a></span> if authentication is needed and fails.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-bulkwriteexception.php" class="classname">MongoDB\Driver\Exception\BulkWriteException</a></span> on any write failure (e.g. write error, failure to apply a write concern)</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.php" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> on other errors.</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-server.executebulkwrite-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 2.0.0</td>
       <td>
        The <code class="parameter">options</code> parameter no longer accepts a
        <span class="classname"><a href="class.mongodb-driver-writeconcern.php" class="classname">MongoDB\Driver\WriteConcern</a></span> instance.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.21.0</td>
       <td>
        Passing a <span class="classname"><a href="class.mongodb-driver-writeconcern.php" class="classname">MongoDB\Driver\WriteConcern</a></span> object as
        <code class="parameter">options</code> is deprecated and will be removed in 2.0.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.4.4</td>
       <td>
        <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>
        will be thrown if the <code class="literal">&quot;session&quot;</code> option is used in
        combination with an unacknowledged write concern.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.4.0</td>
       <td>
        The third parameter is now an <code class="parameter">options</code> array.
        For backwards compatibility, this paramater will still accept a
        <span class="classname"><a href="class.mongodb-driver-writeconcern.php" class="classname">MongoDB\Driver\WriteConcern</a></span> object.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.3.0</td>
       <td>
        <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>
        is now thrown if <code class="parameter">bulk</code> does not contain any write
        operations. Previously, a
        <span class="classname"><a href="class.mongodb-driver-exception-bulkwriteexception.php" class="classname">MongoDB\Driver\Exception\BulkWriteException</a></span> was
        thrown.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-mongodb-driver-server.executebulkwrite-notes">
  <h3 class="title">Notes</h3>
  
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    It is the caller&#039;s responsibility to ensure that the server is capable
    of executing the write operation. For example, executing a write operation
    on a secondary (excluding its &quot;local&quot; database) will fail.
   </span>
  </p></blockquote>

 </div>


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


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