<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-server.executewritecommand.php',
    1 => 'MongoDB\\Driver\\Server::executeWriteCommand',
    2 => 'Execute a database command that writes on this server',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-server.php',
    1 => 'MongoDB\\Driver\\Server',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-server.executereadwritecommand.php',
    1 => 'MongoDB\\Driver\\Server::executeReadWriteCommand',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-server.gethost.php',
    1 => 'MongoDB\\Driver\\Server::getHost',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/server/executewritecommand.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-server.executewritecommand" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Server::executeWriteCommand</h1>
  <p class="verinfo">(mongodb &gt;=1.4.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Server::executeWriteCommand</span> &mdash; <span class="dc-title">Execute a database command that writes on this server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-server.executewritecommand-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Server::executeWriteCommand</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$db</code></span>, <span class="methodparam"><span class="type"><a href="class.mongodb-driver-command.php" class="type MongoDB\Driver\Command">MongoDB\Driver\Command</a></span> <code class="parameter">$command</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-cursor.php" class="type MongoDB\Driver\Cursor">MongoDB\Driver\Cursor</a></span></div>

  <p class="para rdfs-comment">
   Executes the command on this server.
  </p>
  <p class="para">
   This method will apply logic that is specific to commands that write (e.g.
   <a href="https://www.mongodb.com/docs/manual/reference/command/drop/" class="link external">&raquo;&nbsp;drop</a>).
   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>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    This method is not intended to be used to execute
    <a href="https://www.mongodb.com/docs/manual/reference/command/insert/" class="link external">&raquo;&nbsp;insert</a>,
    <a href="https://www.mongodb.com/docs/manual/reference/command/update/" class="link external">&raquo;&nbsp;update</a>,
    or <a href="https://www.mongodb.com/docs/manual/reference/command/delete/" class="link external">&raquo;&nbsp;delete</a>
    commands. Users are encouraged to use
    <span class="function"><a href="mongodb-driver-server.executebulkwrite.php" class="function">MongoDB\Driver\Server::executeBulkWrite()</a></span> for those
    operations.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-server.executewritecommand-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
   
    <dt><code class="parameter">db</code> (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)</dt>
    <dd>
     <p class="para">
      Назва бази даних, в якій буде виконано команду.
     </p>
    </dd>
   

   
   
    <dt><code class="parameter">command</code> (<span class="classname"><a href="class.mongodb-driver-command.php" class="classname">MongoDB\Driver\Command</a></span>)</dt>
    <dd>
     <p class="para">
      Команда, яку потрібно виконати.
     </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">
            Сеанс, по&#039;язаний з операцією.
           </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">
            Вимога щодо запису.
           </p>
          </td>
         </tr>


        </tbody>
       
      </table>

     </p>
     
     <div class="warning"><strong class="warning">Увага</strong>
      <p class="para">
       Для сеансу (<code class="literal">&quot;session&quot;</code>) транзакції, яка триває, не
       можна задати параметр <code class="literal">&quot;readConcern&quot;</code> або
       <code class="literal">&quot;writeConcern&quot;</code>. Це призведе до викидання виключення
       <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.
       Ці два параметри потрібно задавати під час створення транзакції методом
       <span class="methodname"><a href="mongodb-driver-session.starttransaction.php" class="methodname">MongoDB\Driver\Session::startTransaction()</a></span>.
      </p>
     </div>

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


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-server.executewritecommand-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">У разі успіху повертає примірника
<span class="classname"><a href="class.mongodb-driver-cursor.php" class="classname">MongoDB\Driver\Cursor</a></span>.</p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-server.executewritecommand-errors">
  <h3 class="title">Помилки/виключення</h3>
  <ul class="simplelist">
   <li>Якщо в транзакції параметр
<code class="literal">&quot;session&quot;</code> використано разом з параметром
<code class="literal">&quot;readConcern&quot;</code> або <code class="literal">&quot;writeConcern&quot;</code>,
викидається
<span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li>
   <li>Якщо використано параметр
<code class="literal">&quot;session&quot;</code>, а вимога щодо запису не задоволена, викидається
<span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li>
   <li>У разі помилки обробки параметрів
викидається
<span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li><li>Якщо не вдається з’єднатися з
сервером (з інших причин, ніж автентифікація), то викидається
<span class="classname"><a href="class.mongodb-driver-exception-connectionexception.php" class="classname">MongoDB\Driver\Exception\ConnectionException</a></span>.</li><li>Якщо обов'язкова
автентифікація провалена, то викидається
<span class="classname"><a href="class.mongodb-driver-exception-authenticationexception.php" class="classname">MongoDB\Driver\Exception\AuthenticationException</a></span>.</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 (e.g. invalid command).</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-server.executewritecommand-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <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>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-mongodb-driver-server.executewritecommand-notes">
  <h3 class="title">Примітки</h3>
  
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    На програміста покладено роль визначити спроможність сервера
    виконувати операції запису. До прикладу, операція запису на другорядному
    вузлі (за винятком &quot;локальної&quot; БД) буде невдалою.
   </span>
  </p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-server.executewritecommand-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="classname"><a href="class.mongodb-driver-command.php" class="classname">MongoDB\Driver\Command</a></span></li>
   <li><span class="classname"><a href="class.mongodb-driver-cursor.php" class="classname">MongoDB\Driver\Cursor</a></span></li>
   <li><span class="function"><a href="mongodb-driver-server.executecommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeCommand()</a> - Execute a database command on this server</span></li>
   <li><span class="function"><a href="mongodb-driver-server.executereadcommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeReadCommand()</a> - Execute a database command that reads on this server</span></li>
   <li><span class="function"><a href="mongodb-driver-server.executereadwritecommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeReadWriteCommand()</a> - Execute a database command that reads and writes on this server</span></li>
   <li><span class="function"><a href="mongodb-driver-manager.executewritecommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Manager::executeWriteCommand()</a> - Execute a database command that writes</span></li>
  </ul>
 </div>


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