CakeFest 2024: The Official CakePHP Conference

MongoDB\Driver\Manager::executeWriteCommand

(mongodb >=1.4.0)

MongoDB\Driver\Manager::executeWriteCommandExecute a database command that writes

Descripción

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

Executes the command on the primary 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\Manager::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.

Ver también

add a note

User Contributed Notes

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