DatabaseConnectionFactory.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace App\Database;
use App\Database\MySQL\AutoRetryMySqlConnection;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\Connection;
/**
* Class DatabaseConnectionFactory
*
* @package App\Database
*/
class DatabaseConnectionFactory extends ConnectionFactory
{
/**
* Create a new connection instance.
*
* @param string $driver
* @param \PDO|\Closure $connection
* @param string $database
* @param string $prefix
* @param array $config
* @return \Illuminate\Database\Connection
*
* @throws \InvalidArgumentException
*/
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($driver !== 'mysql') {
return parent::createConnection($driver, $connection, $database, $prefix, $config);
}
if ($resolver = Connection::getResolver($driver)) {
return $resolver($connection, $database, $prefix, $config);
}
return new AutoRetryMySqlConnection($connection, $database, $prefix, $config);
}
}