MongoDB\Driver\Session::startTransaction

(mongodb >=1.5.0)

MongoDB\Driver\Session::startTransactionStarts a transaction

Description

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

Liste de paramètres

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
OptionTypeDescription
maxCommitTimeMSinteger

Le temps maximum en millisecondes pour permettre à une seule commande commitTransaction de s'exécuter.

Si spécifié, maxCommitTimeMS doit être un entier 32 bits signé supérieur ou égal à zéro.

readConcernMongoDB\Driver\ReadConcern

Une préoccupation de lecture à appliquer à l'opération.

Cette option est disponible dans MongoDB 3.2+ et se traduira par une exception au moment de l'exécution si elle est spécifiée pour une version plus ancienne du serveur.

readPreferenceMongoDB\Driver\ReadPreference

Une préférence de lecture à utiliser pour sélectionner un serveur pour l'opération.

writeConcernMongoDB\Driver\WriteConcern

Une préoccupation d'écriture à appliquer à l'opération.

Valeurs de retour

Aucune valeur n'est retournée.

Erreurs / Exceptions

Historique

VersionDescription
PECL mongodb 1.6.0

The "maxCommitTimeMS" option was added.

Voir aussi

To Top