MongoDB\Driver\Session::startTransaction
(mongodb >=1.5.0)
MongoDB\Driver\Session::startTransaction — Starts a transaction
说明
   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 integer The maximum amount of time in milliseconds to allow a single
commitTransactioncommand to run.If specified,
maxCommitTimeMSmust be a signed 32-bit integer greater than or equal to zero.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.
 
返回值
没有返回值。
错误/异常
- Throws MongoDB\Driver\Exception\InvalidArgumentException on argument parsing errors.
 - Throws MongoDB\Driver\Exception\CommandException if 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 transaction could not be started (e.g. a transaction was already started).
 
更新日志
| 版本 | 说明 | 
|---|---|
| PECL mongodb 1.6.0 | 
         
         The   | 
      
参见
- MongoDB\Driver\Manager::startSession() - Start a new client session for use with this client
 - MongoDB\Driver\Session::commitTransaction() - Commits a transaction
 - MongoDB\Driver\Session::abortTransaction() - Aborts a transaction
 
用户贡献的备注
备份地址:http://www.lvesu.com/blog/php/mongodb-driver-session.starttransaction.php