I just noticed that while importing some data to a MySQL database using PHP and RedBean (and a transaction) I could see the number of rows growing while the import was running. To confirm my suspicion I changed the R::commit()
to R::rollback()
at the end of the import function and attempted an import. Indeed, the data was imported and permanent even though I called rollback.
I have no idea why the transaction isn't doing it's job and no idea where to start looking, hence this question. Here's the import part of the function. Let me specify that apart from the transaction not working the import function is working great, so there's no need to dissect it.
Thanks for any and all hypotheses
AHA! Got it. Eager to prove @furier wrong I looked up the RedBean transaction documentation and stumbled upon a very helpful note:
Many databases automatically commit after changing schemas, so make sure you test your transactions after
R::freeze(true);
!
So to summarize, some databases may autocommit if you haven't frozen RedBean using R::freeze(true);
breaking all transaction action in your application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With