MongoDB\Driver\Session
PHP Manual

MongoDB\Driver\Session::startTransaction

(mongodb >=1.5.0)

MongoDB\Driver\Session::startTransactionStarts a transaction

Description

final public void MongoDB\Driver\Session::startTransaction ( array|object $options )

This method starts a new transaction within this session. When the session is attached to operations through the "session" argument, these operations become of the started 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 terminated through MongoDB\Driver\Session::endSession().

Parameters

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
readConcern MongoDB\Driver\ReadConcern

A read concern to apply to the operation.

This option is available in MongoDB 3.2+ and will result in an exception at execution time if specified for an older server version.

readPreference MongoDB\Driver\ReadPreference

A read preference to use for selecting a server for the operation.

writeConcern MongoDB\Driver\WriteConcern

A write concern to apply to the operation.

Return Values

No value is returned.

Errors/Exceptions

See Also


MongoDB\Driver\Session
PHP Manual