Dutch PHP Conference 2025 - Call For Papers

MongoDB\Driver\Server::executeWriteCommand

(mongodb >=1.4.0)

MongoDB\Driver\Server::executeWriteCommandExecute a database command that writes on this server

Опис

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

Executes the command on this server.

This method will apply logic that is specific to commands that write (e.g. » drop). The default value for the "writeConcern" option will be inferred from an active transaction (indicated by the "session" option), followed by the connection URI.

Зауваження: This method is not intended to be used to execute » insert, » update, or » delete commands. Users are encouraged to use MongoDB\Driver\Server::executeBulkWrite() for those operations.

Параметри

db (string)

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

command (MongoDB\Driver\Command)

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

options

options
Option Type Description
session MongoDB\Driver\Session

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

writeConcern MongoDB\Driver\WriteConcern

Вимога щодо запису.

Увага

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

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

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

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

Журнал змін

Версія Опис
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.

Примітки

Зауваження: На програміста покладено роль визначити спроможність сервера виконувати операції запису. До прикладу, операція запису на другорядному вузлі (за винятком "локальної" БД) буде невдалою.

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

add a note

User Contributed Notes

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