Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added documentation to nested transactions.

  • Loading branch information...
commit 32ae2eaf78ee4739720492131d15d0a477542883 1 parent 2fbf875
@jrbasso authored
View
8 en/appendices/2-2-migration-guide.rst
@@ -15,6 +15,13 @@ Models
As the pagination of custom find methods never worked quite well it required
workarounds for this in the model level, which are now no longer needed
+Datasources
+===========
+
+- Dbo datasources now supports real transactions. If you get some problem in your
+ application related with that, disable it using
+ ``ConnectionManager::getDataSource('default')->nestedTransaction = false;``
+
Testing
=======
@@ -66,4 +73,3 @@ FormHelper
honours the ``on`` key.
- :php:meth:`FormHelper::radio()` now supports an ``empty`` which works similar
to the empty option on ``select()``.
-
View
5 en/appendices/new-features-in-cakephp-2-2.rst
@@ -12,6 +12,11 @@ Models
As the pagination of custom find methods never worked quite well it required
workarounds for this in the model level, which are now no longer needed
+Datasources
+===========
+
+- Dbo datasources now supports real transactions.
@ADmad
ADmad added a note

This statement doesn't seem very accurate. Transactions were already supported just not nested transactions.

@jrbasso Owner
jrbasso added a note

Thanks, fixed on 89bc1fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
Pagination
==========
View
28 en/models/transactions.rst
@@ -19,18 +19,38 @@ transactions.
<?php
$dataSource->begin();
-
+
// Perform some tasks
-
+
if (/*all's well*/) {
$dataSource->commit();
} else {
$dataSource->rollback();
}
-Transaction nesting support. Now it is possible to start a transaction several times. It will only be committed if the commit method is called the same amount of times.
+Nested Transactions
+-------------------
+
+It is possible to start a transaction several times using the
+:php:meth:`Datasource::begin()` method. The transaction will finish only when
+the number of `commit` and `rollback` match with begin's.
+
+::
+
+ <?php
+ $dataSource->begin();
+ // Perform some tasks
+ $dataSource->begin();
+ // More few tasks
+ if (/*latest task ok*/) {
+ $dataSource->commit();
+ } else {
+ $dataSource->rollback();
+ // Change something in main task
+ }
+ $dataSource->commit();
.. meta::
:title lang=en: Transactions
- :keywords lang=en: transaction methods,datasource,rollback,data source
+ :keywords lang=en: transaction methods,datasource,rollback,data source,begin,commit,nested transaction
Please sign in to comment.
Something went wrong with that request. Please try again.