A ``Doctrine\DBAL\Connection`` provides a PDO-like API for
transaction management, with the methods
``Connection#beginTransaction()``, ``Connection#commit()`` and
``Connection#rollback()``.
``Connection#rollBack()``.
Transaction demarcation with the Doctrine DBAL looks as follows:
...
...
@@ -16,7 +16,7 @@ Transaction demarcation with the Doctrine DBAL looks as follows:
// do stuff
$conn->commit();
} catch(Exception $e) {
$conn->rollback();
$conn->rollBack();
throw $e;
}
...
...
@@ -60,9 +60,9 @@ transactions, or rather propagating transaction control up the call
stack. For that purpose, the ``Connection`` class keeps an internal
counter that represents the nesting level and is
increased/decreased as ``beginTransaction()``, ``commit()`` and
``rollback()`` are invoked. ``beginTransaction()`` increases the
``rollBack()`` are invoked. ``beginTransaction()`` increases the
nesting level whilst
``commit()`` and ``rollback()`` decrease the nesting level. The nesting level starts at 0. Whenever the nesting level transitions from 0 to 1, ``beginTransaction()`` is invoked on the underlying driver connection and whenever the nesting level transitions from 1 to 0, ``commit()`` or ``rollback()`` is invoked on the underlying driver, depending on whether the transition was caused by ``Connection#commit()`` or ``Connection#rollback()``.
``commit()`` and ``rollBack()`` decrease the nesting level. The nesting level starts at 0. Whenever the nesting level transitions from 0 to 1, ``beginTransaction()`` is invoked on the underlying driver connection and whenever the nesting level transitions from 1 to 0, ``commit()`` or ``rollBack()`` is invoked on the underlying driver, depending on whether the transition was caused by ``Connection#commit()`` or ``Connection#rollBack()``.
What this means is that transaction control is basically passed to
code higher up in the call stack and the inner transaction block is
...
...
@@ -91,7 +91,7 @@ example:
$conn->commit(); // 2 => 1
} catch (Exception $e) {
$conn->rollback(); // 2 => 1, transaction marked for rollback only
$conn->rollBack(); // 2 => 1, transaction marked for rollback only