You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered: