I have this little problem with Laravel 4.2 and DB :: transaction. I had a problem with rollback transactions, so I tried the simplest piece of code and put it in route.php for testing:
routes.php:
DB::transaction(function(){ $user = App::make("User"); $user->save(); throw new Exception("Should not create users"); }); ... ... ... Some other code here
I'm just trying to create a user when closing a transaction, and after creating the user, I make an exception to force the transaction to roll back. My problem is that even you have thrown an exception, the transaction is not a rollback. I get a new user in the database every time I update the application. The same code works as on the local computer, but on the server that I plan to use to produce it, it just does not roll back the transaction. Do you have any idea why?
EDIT:
MySql Server: 5.1.73-cll - MySQL Community Server (GPLv2)
PHP server: PHP 5.4.30 (cli) (built: July 19, 2014 15:22:18)
Local PHP: 5.5.9
Local MySql: 5.6.16
The server is on CentOs, and the local computer is on Windows 7.
database php mysql laravel
MikeWu Jul 24 '14 at 23:26 2014-07-24 23:26
source share