-
Notifications
You must be signed in to change notification settings - Fork 66
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
What about transactions? #111
Comments
@crocodile2u Looks about right 👍 Do you feel there's something that needs to be done here? PRs would be much appreciated |
Yeah, I think a |
As this library i quite low-level, i think such a method would be better suited in a package providing a higher-level abstraction on top of this library, think of something like Doctrine DBAL which provides an abstraction on top of PDO. Other than that, documentation improvements are very welcome 👍 |
Just on transactions: I think I'm right that the code above has a (possibly) unexpected behaviour. Specifically, while the database is handling BEGIN, other queries may be sent to the database from elsewhere in the PHP script, and then surprise: these will be executed within the scope of this transaction. That is, the entire PHP script's queries will be in the transaction, and not only the queries in the specific chain of ->then() calls above. I think the only way to really isolate a specific thread of ->then() calls in a transaction that is not shared by the rest of the script, is to open an entirely separate connection instead of running BEGIN. Let me know if I'm somehow wrong on this; otherwise, I thought worth mentioning for future readers! |
When we do transactions it should be very clear that we start a transactions, preferably from this package's API directly |
That's a nasty behavior. That place elsewhere in the PHP script might send it's own BEGIN. MySQL doesn't handle nested transactions, therefore it's going to result in an error. |
Could this be something added to the |
Therefore any transaction should probably occur in its own connection. |
Hello there, 2.5 years later since last message I created a simple wrapper around |
Atomicity of operations is a vital part of any application. How do you handle transactions? I reckon, one can just make it this (simplified):
Would be nice to have this covered in docs.
The text was updated successfully, but these errors were encountered: