DBAL-873: [GH-571] Introduced a Transaction object #2113

Closed
doctrinebot opened this Issue Apr 18, 2014 · 1 comment

3 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

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

Url: #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!

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-571] was closed:
#571

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@deeky666 deeky666 added New Feature and removed Bug labels Jan 5, 2016
@beberlei beberlei was unassigned by deeky666 Jan 5, 2016
@deeky666 deeky666 closed this Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment