CakeFest 2024: The Official CakePHP Conference

MongoDB\Driver\Server::executeWriteCommand

(mongodb >=1.4.0)

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

Descripción

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) and take the MongoDB server version into account. The "writeConcern" option will default to the corresponding value from the MongoDB Connection URI.

Nota: 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 commands.

Parámetros

db (string)

El nombre de la base de datos en la que ejecutar el comando.

command (MongoDB\Driver\Command)

El comando a ejecutar.

options

options
Option Type Description
session MongoDB\Driver\Session

Una sesión a asociar con la operación.

writeConcern MongoDB\Driver\WriteConcern

Un asunto de escritura a aplicar a la operación.

Advertencia

Si se usa la opción "session" con sesión que tenga una transacción en progreso, no se puede especificar una opción "readConcern" o "writeConcern". Esto resultarña en una MongoDB\Driver\Exception\InvalidArgumentException. En su lugar se debería establecer estas dos opciones al crear la transacción con MongoDB\Driver\Session::startTransaction().

Valores devueltos

Devuelve un MongoDB\Driver\Cursor en caso de éxito.

Errores/Excepciones

Historial de cambios

Versión Descripción
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.

Notas

Nota: Es responsabilidad del llamador asegurarse de que el servidor es capaz de ejecutar la operación de escritura. Por ejemplo, ejecutar un operación de escritura en un secundario (excluyendo su base de datos "local"), fallará.

Ver también

add a note

User Contributed Notes

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