CakeFest 2024: The Official CakePHP Conference

MongoDB\Driver\Session::startTransaction

(mongodb >=1.5.0)

MongoDB\Driver\Session::startTransactionStarts a transaction

Descrição

final public MongoDB\Driver\Session::startTransaction(?array $options = null): void

Starts a multi-document transaction associated with the session. At any given time, you can have at most one open transaction for a session. After starting a transaction, the session object must be passed to each operation via the "session" option (e.g. MongoDB\Driver\Manager::executeBulkWrite()) in order to associate that operation with the transaction.

Transactions can be committed through MongoDB\Driver\Session::commitTransaction(), and aborted with MongoDB\Driver\Session::abortTransaction(). Transactions are also automatically aborted when the session is closed from garbage collection or by explicitly calling MongoDB\Driver\Session::endSession().

Parâmetros

options

Options can be passed as argument to this method. Each element in this options array overrides the corresponding option from the "defaultTransactionOptions" option, if set when starting the session with MongoDB\Driver\Manager::startSession().

options
Option Type Description
maxCommitTimeMS integer

A quantidade máxima de tempo em milissegundos para permitir que um único comando commitTransaction seja executado.

Se especificada, maxCommitTimeMS deve ser um inteiro de 32 bits com sinal com valor maior ou igual a zero.

readConcern MongoDB\Driver\ReadConcern

Um read concern a ser aplicado à operação.

Esta opção está disponível no MongoDB 3.2+ e resultará em uma exceção em tempo de execução se for especificada para uma versão de servidor mais antiga.

readPreference MongoDB\Driver\ReadPreference

Uma preferência de leitura a ser usada para selecionar um servidor para a operação.

writeConcern MongoDB\Driver\WriteConcern

Um write concern a ser aplicado à operação.

Valor Retornado

Nenhum valor é retornado.

Erros/Exceções

Registro de Alterações

Versão Descrição
PECL mongodb 1.6.0

The "maxCommitTimeMS" option was added.

Veja Também

add a note

User Contributed Notes

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