php - Laravel DB::transaction not rolling back on exception -
I have this small problem with Laravel 4.2 and DB :: transactions. I had a problem with the transaction which was not being brought back, so I tried to snippet the code the easiest and put it in the routes for testing purposes. Php:
routes.php:
DB :: transaction (task () ($ user = app :: build ("user"); $ user-> gt; ; Save (); Throw a new exception ("Do not create user");}); ... ... ... some other code here Just within the closing of the transaction Trying to create a user and after creating the user, I make an exception to force the rollback of the transaction. My problem is that you throw exceptions, I do not roll, whenever I refresh the app, every time I am getting a new user in the database, the same code works for the purpose of a local machine, but I am planning to use it for production on the server Do not roll back the transaction. Do you have any ideas?
Edit:
Server MySql: 5.1.73-cll - MySQL Community Server (GPLv2) < / P>
Server PHP: PHP 5.4.30 (CLI) (Local Local Created 1: 5.5.9
Local MySql: 5.6.16
The server is sitting on the centers, while the local machine is Windows 7.
So I am answering my question. InnoDb was not a default storage engine until MySql 5.5. In my case MYISAM was the default storage engine and did not support the transaction. What I had to do was Ennobi-enabled in my CPNL server installation of MySQL, I had to make sure that each of my Laurellal migration was made with the Indobi engine. I did this by adding:
$ table-> Engine = "indibe"; On each migration file Once all the tables were installed with the Inodb engine, work with the purpose of the transaction.
Comments
Post a Comment