Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-873

[GH-571] Introduced a Transaction object

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      This issue is created automatically through a Github pull request on behalf of BenMorel:

      Url: https://github.com/doctrine/dbal/pull/571

      Message:

      This is a first draft on the idea of a Transaction object, as suggested by @guilhermeblanco and @beberlei in doctrine/doctrine2#949.

      This makes the following changes to `Connection`:

      • *Adds* the following methods:
      • `createTransaction()` : begins a transaction and returns the associated `Transaction` object
      • `getTransactionManager()` : returns the `TransactionManager`
      • *Deprecates* `beginTransaction()` in favour of `createTransaction()`
      • *Deprecates* the following methods, in favour of their counterparts on `Transaction`:
      • `commit()`
      • `rollBack()`
      • `setRollbackOnly()`
      • `isRollbackOnly()`
      • *Deprecates* the following methods, in favour of their counterparts on `TransactionManager`:
      • `isTransactionActive()`
      • `getTransactionNestingLevel()`
      • `setNestTransactionsWithSavepoints()`
      • `getNestTransactionsWithSavepoints()`

      The new way of dealing with transactions is then:

      $transaction = $connection->createTransaction();
      $transaction->commit();

      It also automatically propagates `commit()` and `rollback()` to nested transactions:

      $transaction1 = $connection->createTransaction();
      $transaction2 = $connection->createTransaction();
      $transaction1->commit(); // will commit $transaction2 then $transaction1

      Overall, it's not a complicated change, does not introduce any BC break, and passes all existing tests.

      I'm looking forward to hearing what you think!

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Doctrine Bot
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: