From c26c53aec6f52e4fec9a3e666214bb7548f0ad9d Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 22 Jun 2018 16:19:51 +0000 Subject: [PATCH] Add (basic) documentation for MongoDB 4.0+ transactions. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345182 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../mongodb/driver/manager/startsession.xml | 59 +++++++++ .../driver/session/aborttransaction.xml | 73 +++++++++++ .../driver/session/committransaction.xml | 80 ++++++++++++ .../mongodb/driver/session/endsession.xml | 73 +++++++++++ .../driver/session/starttransaction.xml | 116 ++++++++++++++++++ reference/mongodb/versions.xml | 4 + 6 files changed, 405 insertions(+) create mode 100644 reference/mongodb/mongodb/driver/session/aborttransaction.xml create mode 100644 reference/mongodb/mongodb/driver/session/committransaction.xml create mode 100644 reference/mongodb/mongodb/driver/session/endsession.xml create mode 100644 reference/mongodb/mongodb/driver/session/starttransaction.xml diff --git a/reference/mongodb/mongodb/driver/manager/startsession.xml b/reference/mongodb/mongodb/driver/manager/startsession.xml index 1153bc42dd..5d32657e1d 100644 --- a/reference/mongodb/mongodb/driver/manager/startsession.xml +++ b/reference/mongodb/mongodb/driver/manager/startsession.xml @@ -62,6 +62,40 @@ &true; + + defaultTransactionOptions + array + + + Default options to apply to newly created transactions. These + options are used unless they are overridden when a transaction is + started with different value for each option. + + + + options + + + + Option + Type + Description + + + + &mongodb.option.readConcern; + &mongodb.option.readPreference; + &mongodb.option.writeConcern; + + +
+
+ + This option is available in MongoDB 4.0+. + +
+ +
@@ -86,6 +120,31 @@ + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 1.5.0 + + + The "defaultTransactionOptions" option was added. + + + + + + + + &reftitle.seealso; diff --git a/reference/mongodb/mongodb/driver/session/aborttransaction.xml b/reference/mongodb/mongodb/driver/session/aborttransaction.xml new file mode 100644 index 0000000000..e1a0ac04eb --- /dev/null +++ b/reference/mongodb/mongodb/driver/session/aborttransaction.xml @@ -0,0 +1,73 @@ + + + + + + MongoDB\Driver\Session::abortTransaction + Aborts a transaction + + + + &reftitle.description; + + final public voidMongoDB\Driver\Session::abortTransaction + + + + This method aborts an existing transaction and all the associated + operations are rolled back. It is like all operations that were part of + this transaction never existed. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + &mongodb.throws.argumentparsing; + Throws MongoDB\Driver\Exception\RuntimeException if the the transaction could not be aborted (e.g. a transaction was not started). + + + + + &reftitle.seealso; + + MongoDB\Driver\Manager::startSession + MongoDB\Driver\Session::commitTransaction + MongoDB\Driver\Session::startTransaction + + + + + + diff --git a/reference/mongodb/mongodb/driver/session/committransaction.xml b/reference/mongodb/mongodb/driver/session/committransaction.xml new file mode 100644 index 0000000000..b731047d20 --- /dev/null +++ b/reference/mongodb/mongodb/driver/session/committransaction.xml @@ -0,0 +1,80 @@ + + + + + + MongoDB\Driver\Session::commitTransaction + Commits a transaction + + + + &reftitle.description; + + final public voidMongoDB\Driver\Session::commitTransaction + + + + This method commits an existing transaction and all the associated + operations are persisted in the database. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + &mongodb.throws.argumentparsing; + Throws + MongoDB\Driver\Exception\CommandException if the + server could not commit the transaction (e.g. due to conflicts, network + issues). In case the exception's + MongoDB\Driver\Exception\CommandException::getResultDocument + has a "errorLabels" element, and this array contains a + "TransientTransactionError" value, it is safe to re-try + the whole transaction. + Throws MongoDB\Driver\Exception\RuntimeException if the transaction could not be commited (e.g. a transaction was not started). + + + + + &reftitle.seealso; + + MongoDB\Driver\Manager::startSession + MongoDB\Driver\Session::commitTransaction + MongoDB\Driver\Session::startTransaction + + + + + + diff --git a/reference/mongodb/mongodb/driver/session/endsession.xml b/reference/mongodb/mongodb/driver/session/endsession.xml new file mode 100644 index 0000000000..96fec21057 --- /dev/null +++ b/reference/mongodb/mongodb/driver/session/endsession.xml @@ -0,0 +1,73 @@ + + + + + + MongoDB\Driver\Session::endSession + Terminates a session + + + + &reftitle.description; + + final public voidMongoDB\Driver\Session::endSession + + + + This method closes an existing session. If a transaction was associated + with this session, this transaction is also aborted, and all its + operations are rolled back. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + &mongodb.throws.argumentparsing; + + + + + &reftitle.seealso; + + MongoDB\Driver\Manager::startSession + MongoDB\Driver\Session::abortTransaction + MongoDB\Driver\Session::commitTransaction + MongoDB\Driver\Session::startTransaction + + + + + + diff --git a/reference/mongodb/mongodb/driver/session/starttransaction.xml b/reference/mongodb/mongodb/driver/session/starttransaction.xml new file mode 100644 index 0000000000..09bc01fec7 --- /dev/null +++ b/reference/mongodb/mongodb/driver/session/starttransaction.xml @@ -0,0 +1,116 @@ + + + + + + MongoDB\Driver\Session::startTransaction + Starts a transaction + + + + &reftitle.description; + + final public voidMongoDB\Driver\Session::startTransaction + array|objectoptions + + + 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. + + + + + &reftitle.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 + + + + &mongodb.option.readConcern; + &mongodb.option.readPreference; + &mongodb.option.writeConcern; + + +
+
+
+
+
+
+ + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + &mongodb.throws.argumentparsing; + 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). + + + + + &reftitle.seealso; + + MongoDB\Driver\Manager::startSession + MongoDB\Driver\Session::commitTransaction + MongoDB\Driver\Session::abortTransaction + + + +
+ + diff --git a/reference/mongodb/versions.xml b/reference/mongodb/versions.xml index 07e9232780..5e8a91d819 100644 --- a/reference/mongodb/versions.xml +++ b/reference/mongodb/versions.xml @@ -87,11 +87,15 @@ + + + +