Commit 2be8242a authored by Steve Müller's avatar Steve Müller

fix retrieving the database name connected to for SQL Server

parent 41e718ea
......@@ -78,7 +78,11 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr
{
$params = $conn->getParams();
return $params['dbname'];
if (isset($params['dbname'])) {
return $params['dbname'];
}
return $conn->query('SELECT DB_NAME()')->fetchColumn();
}
/**
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
class DriverTest extends AbstractDriverTest
{
protected function setUp()
{
if (! extension_loaded('pdo_sqlsrv')) {
$this->markTestSkipped('pdo_sqlsrv is not installed.');
}
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_sqlsrv only test.');
}
}
/**
* {@inheritdoc}
*/
protected function createDriver()
{
return new Driver();
}
/**
* {@inheritdoc}
*/
protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
{
return 'master';
}
}
<?php
namespace Doctrine\Tests\DBAL\Functional\Driver\SQLSrv;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
class DriverTest extends AbstractDriverTest
{
protected function setUp()
{
if (! extension_loaded('sqlsrv')) {
$this->markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlsrv only test.');
}
}
/**
* {@inheritdoc}
*/
protected function createDriver()
{
return new Driver();
}
/**
* {@inheritdoc}
*/
protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
{
return 'master';
}
}
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