Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't RedBean's transaction functions working?

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

like image 341
Hubro Avatar asked Dec 26 '22 23:12

Hubro


1 Answers

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

like image 96
Hubro Avatar answered Jan 05 '23 00:01

Hubro