Dutch PHP Conference 2025 - Call For Papers

MongoDB\Driver\Session::startTransaction

(mongodb >=1.5.0)

MongoDB\Driver\Session::startTransactionStarts a transaction

Опис

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().

Параметри

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 int

Час (у мілісекундах), що відводиться на виконання однієї команди commitTransaction.

Параметр maxCommitTimeMS повинен бути знаковим 32-бітним цілим числом, що рівне або більше за нуль.

readConcern MongoDB\Driver\ReadConcern

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

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

readPreference MongoDB\Driver\ReadPreference

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

writeConcern MongoDB\Driver\WriteConcern

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

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

Не повертає значень.

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

Журнал змін

Версія Опис
PECL mongodb 1.6.0

The "maxCommitTimeMS" option was added.

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

add a note

User Contributed Notes

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