Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-Transaction Handle #5

Closed
ondrej-bouda opened this issue Sep 27, 2017 · 1 comment
Closed

Auto-Transaction Handle #5

ondrej-bouda opened this issue Sep 27, 2017 · 1 comment

Comments

@ondrej-bouda
Copy link
Owner

ondrej-bouda commented Sep 27, 2017

  • ITxHandle::rollbackIfOpen() allows for pretty easy exception handling within open transactions. It still requires one to think of it and type some boilerplate code. In some cases (and arguably in the typical ones), just a single transaction is started and committed/rolled back within one function/method.
  • Implement ITransactionControl::startAutoTransaction() which would return a specialization of TxHandle, calling rollbackIfOpen() in __destruct(). That would even simplify the typical case:
function foo() {
    $tx = $conn->startAutoTransaction();
    // do stuff, exceptions expected
    $tx->commit();
}
  • The term "auto transaction" might mislead one to think even commit() call is implicit. Reconsider the term or behaviour.
  • While at it, reconsider whether ICoreFactory::createTransactionHandle() is really reasonable.
  • Also applicable to nested transactions - see Nested Transactions #6.
ondrej-bouda pushed a commit that referenced this issue Jul 1, 2020
@ondrej-bouda
Copy link
Owner Author

Implemented in 91fd365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant