(mongodb >=1.0.0)
MongoDB\Driver\Server::executeCommand â Execute a database command on this server
$db, MongoDB\Driver\Command $command, ?array $options = null): MongoDB\Driver\CursorExecutes the command on this server.
This method applies no special logic to the command. The
Default values for the "readPreference",
"readConcern", and "writeConcern"
options will be inferred from an active transaction (indicated by the
"session" option). If there is no active transaction, a
primary read preference will be used for server selection.
Default values will not be inferred from the connection URI. Users are therefore encouraged to use specific read and/or write command methods if possible.
Hinweis: Die Option
"readPreference"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.
db (string)The name of the database on which to execute the command.
command (MongoDB\Driver\Command)Der auszufĂźhrende Befehl.
options
| Option | Type | Description |
|---|---|---|
| readConcern | MongoDB\Driver\ReadConcern |
Ein Leseanliegen (Read Concern), das auf den Vorgang angewendet werden soll. 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. |
| readPreference | MongoDB\Driver\ReadPreference |
Eine Lesepräferenz, die verwendet wird, um einen Server fßr die Operation auszuwählen. |
| session | MongoDB\Driver\Session |
Eine Session, die mit dem Vorgang verknĂźpft werden soll. |
| writeConcern | MongoDB\Driver\WriteConcern |
Eine Schreibanweisung (Write Concern), das auf den Vorgang angewendet werden soll. |
If you are using a "session" which has a transaction
in progress, you cannot specify a "readConcern" or
"writeConcern" option. This will result in an
MongoDB\Driver\Exception\InvalidArgumentException
being thrown. Instead, you should set these two options when you create
the transaction with
MongoDB\Driver\Session::startTransaction().
Gibt bei Erfolg einen MongoDB\Driver\Cursor zurĂźck.
"session" mit einer zugehÜrigen Transaktion in Kombination mit einer der Optionen "readConcern" oder "writeConcern" verwendet wird."session" in Kombination mit einer unbestätigten Schreibanweisung verwendet wird.| Version | Beschreibung |
|---|---|
| PECL mongodb 2.0.0 |
The options parameter no longer accepts a
MongoDB\Driver\ReadPreference instance.
|
| PECL mongodb 1.21.0 |
Passing a MongoDB\Driver\ReadPreference object as
options is deprecated and will be removed in 2.0.
|
| PECL mongodb 1.4.4 |
MongoDB\Driver\Exception\InvalidArgumentException
will be thrown if the "session" option is used in
combination with an unacknowledged write concern.
|
| PECL mongodb 1.4.0 |
The third parameter is now an options array.
For backwards compatibility, this paramater will still accept a
MongoDB\Driver\ReadPreference object.
|
Hinweis: 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 "lokalen" Datenbank) fehl.