Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
fix create supported platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 1, 2020
1 parent 67544f9 commit 7715a0a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,15 @@ protected static function connectDbalConnection(array $dsn)
// https://github.com/doctrine/dbal/blob/3.0.0/src/DriverManager.php#L142
// TODO probably drop support later
if (self::isComposerDbal2x()) {
$dbalConnection = DriverManager::getConnection([
'pdo' => $pdo,
]);
$dbalConnectionParams = ['pdo' => $pdo];
$driverName = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
if ($driverName === 'pgsql') {
$dbalConnectionParams['driverClass'] = PostgreSQL94Platform::class;
} elseif ($driverName === 'sqlsrv') {
$dbalConnectionParams['driverClass'] = SQLServer2012Platform::class;
}

$dbalConnection = DriverManager::getConnection($dbalConnectionParams);
} else {
$pdoConnection = (new \ReflectionClass(\Doctrine\DBAL\Driver\PDO\Connection::class))
->newInstanceWithoutConstructor();
Expand Down

0 comments on commit 7715a0a

Please sign in to comment.