6

In laravel 5.5 with MySQL I use \Illuminate\Support\Facades\DB to create transactions this way:

DB::transaction(function() {
    ...
});

What is the isolation level for such transaction and is there a way to set it explicitly?

1 Answers1

10

The default in SqlLite is

'BEGIN IMMEDIATE TRANSACTION';

The default in MySQL is

'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';

You can set it yourself by doing something like this

$pdo = DB::connection()->getPdo();
$pdo->exec('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
Lewis Johnson
  • 330
  • 4
  • 15