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?
Transaction Isolation Levels The default isolation level is REPEATABLE READ . Other permitted values are READ COMMITTED , READ UNCOMMITTED , and SERIALIZABLE .
four transaction isolation levels in SQL Server 7.0: Uncommitted Read (also called "dirty read"), Committed Read, Repeatable Read, and Serializable.
To set the global isolation level at server startup, use the --transaction-isolation= level option on the command line or in an option file. Values of level for this option use dashes rather than spaces, so the permissible values are READ-UNCOMMITTED , READ-COMMITTED , REPEATABLE-READ , or SERIALIZABLE .
What Does Transaction Isolation Level Mean? The transaction isolation level is a state within databases that specifies the amount of data that is visible to a statement in a transaction, specifically when the same data source is accessed by multiple transactions simultaneously.
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');
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