MongoDB\Driver\Session::commitTransaction
PHP function
Edit on GitHub ✎
(mongodb >=1.5.0)
Commits a transaction
Description
MongoDB\Driver\Session::commitTransaction(): void
Saves the changes made by the operations in the multi-document transaction and ends the transaction. Until the commit, none of the data changes made from within the transaction are visible outside the transaction.
Parameters Parameters
Return Values
Void
Errors/Exceptions
- Throws
MongoDB\Driver\Exception\CommandExceptionif the server could not commit the transaction (e.g. due to conflicts, network issues). In case the exception'sMongoDB\Driver\Exception\CommandException::getResultDocumenthas a"errorLabels"element, and this array contains a"TransientTransactionError"or"UnknownTransactionCommitResult"value, it is safe to re-try the whole transaction. In newer versions of the extension,MongoDB\Driver\Exception\RuntimeException::hasErrorLabelshould be used to test for this situation instead. - Throws
MongoDB\Driver\Exception\RuntimeExceptionif the transaction could not be committed (e.g. a transaction was not started).
See Also
MongoDB\Driver\Manager::startSessionMongoDB\Driver\Session::abortTransactionMongoDB\Driver\Session::startTransactionMongoDB\Driver\Exception\RuntimeException::hasErrorLabel