MongoDB\Driver\Manager::executeReadCommand

Execute a database command that reads

&reftitle.description; final public `MongoDB\Driver\Cursor` `MongoDB\Driver\Manager::executeReadCommand` `string` `db` `MongoDB\Driver\Command` `command` ``array``null```options`&null;

Selects a server according to the `"readPreference"` option and executes the command on that server.

This method will apply logic that is specific to commands that read (e.g. distinct). Default values for the `"readPreference"` and `"readConcern"` options will be inferred from an active transaction (indicated by the `"session"` option), followed by the connection URI.

&reftitle.parameters;
&mongodb.parameter.db; &mongodb.parameter.command;

`options`

- ## options

  Option | Type | Description
  &mongodb.option.readConcern; &mongodb.option.readPreference; &mongodb.option.session;

  &mongodb.option.transactionReadWriteConcern;
&reftitle.returnvalues; &mongodb.returns.cursor;
&reftitle.errors;

&mongodb.throws.session-readwriteconcern; &mongodb.throws.std;
- Throws `MongoDB\Driver\Exception\RuntimeException` on other errors (e.g. invalid command).

&reftitle.seealso;

- `MongoDB\Driver\Command`
- `MongoDB\Driver\Cursor`
- `MongoDB\Driver\Manager::executeCommand`
- `MongoDB\Driver\Manager::executeReadWriteCommand`
- `MongoDB\Driver\Manager::executeWriteCommand`
- `MongoDB\Driver\Server::executeReadCommand`