MongoDB\Driver\Server::executeCommand
(mongodb >=1.0.0)
Execute a database command on this server
Description
Executes 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.
Readpreference
Parameters
optionsOption Type Description TransactionReadWriteConcern
Return Values Cursor
Errors/Exceptions
- Throws
MongoDB\Driver\Exception\RuntimeExceptionon other errors (e.g. invalid command, issuing a write command to a secondary).
Changelog
| Version | Description |
|---|---|
| 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 parameter will still accept a MongoDB\Driver\ReadPreference object. |