Dutch PHP Conference 2025 - Call For Papers

MongoDB\Driver\Manager::executeReadCommand

(mongodb >=1.4.0)

MongoDB\Driver\Manager::executeReadCommandExecute a database command that reads

Опис

final public MongoDB\Driver\Manager::executeReadCommand(string $db, MongoDB\Driver\Command $command, ?array $options = null): MongoDB\Driver\Cursor

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.

Параметри

db (string)

Назва бази даних, в якій буде виконано команду.

command (MongoDB\Driver\Command)

Команда, яку потрібно виконати.

options

options
Option Type Description
readConcern MongoDB\Driver\ReadConcern

Вимога щодо зчитування.

Цей параметр доступний в MongoDB 3.2+, тож його застосування у старіших версіях викине виключення під час виконання.

readPreference MongoDB\Driver\ReadPreference

Параметр читання для вибору сервера для операції.

session MongoDB\Driver\Session

Сеанс, по'язаний з операцією.

Увага

Для сеансу ("session") транзакції, яка триває, не можна задати параметр "readConcern" або "writeConcern". Це призведе до викидання виключення MongoDB\Driver\Exception\InvalidArgumentException. Ці два параметри потрібно задавати під час створення транзакції методом MongoDB\Driver\Session::startTransaction().

Значення, що повертаються

У разі успіху повертає примірника MongoDB\Driver\Cursor.

Помилки/виключення

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top