Commit 26fda1b2 authored by Guilherme Blanco's avatar Guilherme Blanco

Merge pull request #38 from maxromanovsky/master

Fixed: MySQL Driver didn't return Database name if DBAL was initialized using existing PDO instance
parents f62b4a5d 5aec5359
...@@ -71,7 +71,7 @@ class Driver implements \Doctrine\DBAL\Driver ...@@ -71,7 +71,7 @@ class Driver implements \Doctrine\DBAL\Driver
if (isset($params['charset'])) { if (isset($params['charset'])) {
$dsn .= 'charset=' . $params['charset'] . ';'; $dsn .= 'charset=' . $params['charset'] . ';';
} }
return $dsn; return $dsn;
} }
...@@ -93,6 +93,10 @@ class Driver implements \Doctrine\DBAL\Driver ...@@ -93,6 +93,10 @@ class Driver implements \Doctrine\DBAL\Driver
public function getDatabase(\Doctrine\DBAL\Connection $conn) public function getDatabase(\Doctrine\DBAL\Connection $conn)
{ {
$params = $conn->getParams(); $params = $conn->getParams();
return $params['dbname'];
if (isset($params['dbname'])) {
return $params['dbname'];
}
return $conn->query('SELECT DATABASE()')->fetchColumn();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment