MongoDB\Driver\Session::startTransaction

(mongodb >=1.5.0)

MongoDB\Driver\Session::startTransactionStarts a transaction

Description

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

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

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
Option Type Description
readConcern MongoDB\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.

readPreference MongoDB\Driver\ReadPreference

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

writeConcern MongoDB\Driver\WriteConcern

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

Valeurs de retour

Aucune valeur n'est retournée.

Erreurs / Exceptions

  • Lance une exception MongoDB\Driver\InvalidArgumentException lors d'une erreur survenue pendant l'analyse d'un argument.
  • Throws MongoDB\Driver\Exception\CommandException if the the transaction could not be started because of a server-side problem (e.g. a lock could not be obtained).
  • Throws MongoDB\Driver\Exception\RuntimeException if the the transaction could not be started (e.g. a transaction was already started).

Voir aussi