<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-server.executecommand.php',
    1 => 'MongoDB\\Driver\\Server::executeCommand',
    2 => 'Execute a database command on this server',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-server.php',
    1 => 'MongoDB\\Driver\\Server',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-server.executebulkwritecommand.php',
    1 => 'MongoDB\\Driver\\Server::executeBulkWriteCommand',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-server.executequery.php',
    1 => 'MongoDB\\Driver\\Server::executeQuery',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/server/executecommand.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

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

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-server.executecommand-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Server::executeCommand</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 applies no special logic to the command. The
   Default values for the <code class="literal">&quot;readPreference&quot;</code>,
   <code class="literal">&quot;readConcern&quot;</code>, and <code class="literal">&quot;writeConcern&quot;</code>
   options will be inferred from an active transaction (indicated by the
   <code class="literal">&quot;session&quot;</code> option). If there is no active transaction, a
   primary read preference will be used for server selection.
  </p>
  <p class="para">
   Default values will <em>not</em> be inferred from the
   <a href="mongodb-driver-manager.construct.php#mongodb-driver-manager.construct-uri" class="link">connection URI</a>.
   Users are therefore encouraged to use specific read and/or write command
   methods if possible.
  </p>
  
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <span class="simpara">
    Die Option <code class="literal">&quot;readPreference&quot;</code> steuert nicht den Server,
    an den der Treiber die Operation ausgibt; sie wird immer auf diesem
    Serverobjekt ausgeführt. Stattdessen kann sie verwendet werden, wenn die
    Operation an einen sekundären Knoten (von einer Replikatsatzverbindung,
    keinen eigenständigen) oder einen Mongos-Knoten ausgegeben wird, um
    sicherzustellen, dass der Treiber das Übertragungsprotokoll entsprechend
    einstellt bzw. die Lesepräferenz zur Operation hinzufügt.
   </span>
  </p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-server.executecommand-parameters">
  <h3 class="title">Parameter-Liste</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">
      The name of the database on which to execute the command.
     </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">
      Der auszuführende Befehl.
     </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><span class="classname"><a href="class.mongodb-driver-readconcern.php" class="classname">MongoDB\Driver\ReadConcern</a></span></td>
          <td>
           <p class="para">
            Ein Leseanliegen (Read Concern), das auf den Vorgang angewendet
            werden soll.
           </p>
           <p class="para">
            Diese Option ist ab MongoDB 3.2 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>readPreference</td>
          <td><span class="classname"><a href="class.mongodb-driver-readpreference.php" class="classname">MongoDB\Driver\ReadPreference</a></span></td>
          <td>
           <p class="para">
            Eine Lesepräferenz, die verwendet wird, um einen Server für die
            Operation auszuwählen.
           </p>
          </td>
         </tr>


         
         <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">
            Eine Session, die mit dem Vorgang verknüpft werden soll.
           </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">
            Eine Schreibanweisung (Write Concern), das auf den Vorgang
            angewendet werden soll.
           </p>
          </td>
         </tr>


        </tbody>
       
      </table>

     </p>
     
     <div class="warning"><strong class="warning">Warnung</strong>
      <p class="para">
       If you are using a <code class="literal">&quot;session&quot;</code> which has a transaction
       in progress, you cannot specify a <code class="literal">&quot;readConcern&quot;</code> or
       <code class="literal">&quot;writeConcern&quot;</code> option. This will result in an
       <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>
       being thrown. Instead, you should set these two options when you create
       the transaction with
       <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.executecommand-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">Gibt bei Erfolg einen <span class="classname"><a href="class.mongodb-driver-cursor.php" class="classname">MongoDB\Driver\Cursor</a></span> zurück.</p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-server.executecommand-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 die Option <code class="literal">&quot;session&quot;</code> mit einer zugehörigen Transaktion in Kombination mit einer der Optionen <code class="literal">&quot;readConcern&quot;</code> oder <code class="literal">&quot;writeConcern&quot;</code> verwendet wird.</li>
   <li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>, wenn die Option <code class="literal">&quot;session&quot;</code> in Kombination mit einer unbestätigten Schreibanweisung verwendet wird.</li>
   <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><li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-connectionexception.php" class="classname">MongoDB\Driver\Exception\ConnectionException</a></span>, wenn der Aufbau einer Verbindung zum Server fehlschlägt (aus einem anderen Grund als der Authentifizierung).</li><li>Wirft eine <span class="classname"><a href="class.mongodb-driver-exception-authenticationexception.php" class="classname">MongoDB\Driver\Exception\AuthenticationException</a></span>, wenn eine Authentifizierung erforderlich ist und fehlschlägt.</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, issuing a write command to a secondary).</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-server.executecommand-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Beschreibung</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-readpreference.php" class="classname">MongoDB\Driver\ReadPreference</a></span> instance.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.21.0</td>
       <td>
        Passing a <span class="classname"><a href="class.mongodb-driver-readpreference.php" class="classname">MongoDB\Driver\ReadPreference</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-readpreference.php" class="classname">MongoDB\Driver\ReadPreference</a></span> object.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-mongodb-driver-server.executecommand-notes">
  <h3 class="title">Anmerkungen</h3>
  
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <span class="simpara">
    Es liegt in der Verantwortung des aufrufenden Codes, sicherzustellen, dass
    der Server in der Lage ist, den Schreibvorgang auszuführen. So schlägt
    beispielsweise die Ausführung eines Schreibvorgangs auf einem sekundären
    Server (mit Ausnahme seiner &quot;lokalen&quot; Datenbank) fehl.
   </span>
  </p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-server.executecommand-seealso">
  <h3 class="title">Siehe auch</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.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-server.executewritecommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Server::executeWriteCommand()</a> - Execute a database command that writes on this server</span></li>
   <li><span class="function"><a href="mongodb-driver-manager.executecommand.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Manager::executeCommand()</a> - Execute a database command</span></li>
  </ul>
 </div>


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