Skip to content

Commit

Permalink
Added possibility to configure isolation level for mysql connections
Browse files Browse the repository at this point in the history
  • Loading branch information
duxthefux committed Aug 7, 2020
1 parent 75792f4 commit bdf7699
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Illuminate/Database/Connectors/MySqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function connect(array $config)
$connection->exec("use `{$config['database']}`;");
}

$this->configureIsolationLevel($connection, $config);

$this->configureEncoding($connection, $config);

// Next, we will check to see if a timezone has been specified in this config
Expand All @@ -44,7 +46,25 @@ public function connect(array $config)
*
* @param \PDO $connection
* @param array $config
* @return void
* @return void|\PDO
*/
protected function configureIsolationLevel($connection, array $config)
{
if (! isset($config['isolation_level'])) {
return $connection;
}

$connection->prepare(
"SET SESSION TRANSACTION ISOLATION LEVEL '{$config['isolation_level']}'"
)->execute();
}

/**
* Set the connection character set and collation.
*
* @param \PDO $connection
* @param array $config
* @return void|\PDO
*/
protected function configureEncoding($connection, array $config)
{
Expand Down

0 comments on commit bdf7699

Please sign in to comment.