Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 10188

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Execute a database command that reads and writes on this server</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb-driver-server.executereadcommand.html">MongoDB\Driver\Server::executeReadCommand</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb-driver-server.executewritecommand.html">MongoDB\Driver\Server::executeWriteCommand</a></div>
 <div class="up"><a href="class.mongodb-driver-server.html">MongoDB\Driver\Server</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodb-driver-server.executereadwritecommand" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Server::executeReadWriteCommand</h1>
  <p class="verinfo">(mongodb &gt;=1.4.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Server::executeReadWriteCommand</span> &mdash; <span class="dc-title">Execute a database command that reads and writes on this server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-server.executereadwritecommand-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="type"><span class="type MongoDB\Driver\Cursor">MongoDB\Driver\Cursor</span></span> <span class="methodname"><strong>MongoDB\Driver\Server::executeReadWriteCommand</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$db</code></span>
   , <span class="methodparam"><span class="type"><span class="type MongoDB\Driver\Command">MongoDB\Driver\Command</span></span> <code class="parameter">$command</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code><span class="initializer"> = array()</span></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 read and write
   (e.g.
   <a href="https://docs.mongodb.com/manual/reference/command/findAndModify/" class="link external">&raquo;&nbsp;findAndModify</a>)
   and take the MongoDB server version into account. The
   <em>&quot;readConcern&quot;</em> and <em>&quot;writeConcern&quot;</em>
   options will default to the corresponding values from the
   <a href="mongodb-driver-manager.construct.html#mongodb-driver-manager.construct-uri" class="link">MongoDB Connection
   URI</a>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-server.executereadwritecommand-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
   
    <dt>
<code class="parameter">db</code> (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</dt>

    <dd>

     <p class="para">
      The name of the database on which to execute the command.
     </p>
    </dd>

   

   
   
    <dt>
<code class="parameter">command</code> (<a href="class.mongodb-driver-command.html" class="classname">MongoDB\Driver\Command</a>)</dt>

    <dd>

     <p class="para">
      The command 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>readConcern</td>
          <td><a href="class.mongodb-driver-readconcern.html" class="classname">MongoDB\Driver\ReadConcern</a></td>
          <td>
           <p class="para">
            A read concern to apply to the operation.
           </p>
           <p class="para">
            This option is available in MongoDB 3.2+ and will result in an
            exception at execution time if specified for an older server
            version.
           </p>
          </td>
         </tr>


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


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


        </tbody>
       
      </table>

     </p>
     
     <div class="warning"><strong class="warning">Warning</strong>
      <p class="para">
       If you are using a <em>&quot;session&quot;</em> which has a transaction
       in progress, you cannot specify a <em>&quot;readConcern&quot;</em> or
       <em>&quot;writeConcern&quot;</em> option. This will result in an
       <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a>
       being thrown. Instead, you should set these two options when you create
       the transaction with
       <span class="methodname"><a href="mongodb-driver-session.starttransaction.html" class="methodname">MongoDB\Driver\Session::startTransaction()</a></span>.
      </p>
     </div>

    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-server.executereadwritecommand-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">Returns <a href="class.mongodb-driver-cursor.html" class="classname">MongoDB\Driver\Cursor</a> on success.</p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-server.executereadwritecommand-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <ul class="simplelist">
   <li class="member">Throws <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a> if the <em>&quot;session&quot;</em> option is used with an associated transaction in combination with a <em>&quot;readConcern&quot;</em> or <em>&quot;writeConcern&quot;</em> option.</li>
   <li class="member">Throws <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a> if the <em>&quot;session&quot;</em> option is used in combination with an unacknowledged write concern.</li>
   <li class="member">Throws <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a> on argument parsing errors.</li><li class="member">Throws <a href="class.mongodb-driver-exception-connectionexception.html" class="classname">MongoDB\Driver\Exception\ConnectionException</a> if connection to the server fails (for reasons other than authentication).</li><li class="member">Throws <a href="class.mongodb-driver-exception-authenticationexception.html" class="classname">MongoDB\Driver\Exception\AuthenticationException</a> if authentication is needed and fails.</li>
   <li class="member">Throws <a href="class.mongodb-driver-exception-runtimeexception.html" class="classname">MongoDB\Driver\Exception\RuntimeException</a> on other errors (e.g. invalid command).</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-server.executereadwritecommand-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>1.4.4</td>
       <td>
        <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a>
        will be thrown if the <em>&quot;session&quot;</em> 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.executereadwritecommand-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.executereadwritecommand-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><a href="class.mongodb-driver-command.html" class="classname">MongoDB\Driver\Command</a></li>
   <li class="member"><a href="class.mongodb-driver-cursor.html" class="classname">MongoDB\Driver\Cursor</a></li>
   <li class="member"><span class="function"><a href="mongodb-driver-server.executecommand.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeCommand()</a> - Execute a database command on this server</span></li>
   <li class="member"><span class="function"><a href="mongodb-driver-server.executereadcommand.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeReadCommand()</a> - Execute a database command that reads on this server</span></li>
   <li class="member"><span class="function"><a href="mongodb-driver-server.executewritecommand.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeWriteCommand()</a> - Execute a database command that writes on this server</span></li>
   <li class="member"><span class="function"><a href="mongodb-driver-manager.executereadwritecommand.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Manager::executeReadWriteCommand()</a> - Execute a database command that reads and writes</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongodb-driver-server.executereadcommand.html">MongoDB\Driver\Server::executeReadCommand</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodb-driver-server.executewritecommand.html">MongoDB\Driver\Server::executeWriteCommand</a></div>
 <div class="up"><a href="class.mongodb-driver-server.html">MongoDB\Driver\Server</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>