Replies: 1 comment 14 replies
-
We do not really support any other variant to execute transactions via our public API as there is too much that could go wrong with the other approaches. Using a guard object would cause issues if the rollback fails due to whatever reasons as we cannot return any result from the destructor. That all written I would be interested to know in which cases you feel that the current |
Beta Was this translation helpful? Give feedback.
-
I've been using Connection::transaction, to which a closure is passed which comprises the body of the transaction. I'm finding it very hard to compose this with other functions that invoke DB statements. Is there a way to do this more like in plain SQL, where you issue a begin transaction statement, and later issue a commit statement? Perhaps the begin transaction would return a guard object that rolls back the transaction if commit isn't called.
I see TransactionManager trait and AnsiTransactionManager, and it looks like this is meant to be an internal impl detail of Connection, but it also seems like the most promising way to do this sort of procedural transaction invocation. Am I on the right track? Has anyone already done what I'm describing?
Beta Was this translation helpful? Give feedback.
All reactions