Commit c9594979 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Fixed PdoSqlsrv connection DSN

parent 84770cd5
......@@ -30,10 +30,6 @@ class Driver implements \Doctrine\DBAL\Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
if (isset($params['dbname'])) {
$driverOptions['Database'] = $params['dbname'];
}
return new \Doctrine\DBAL\Driver\PDOConnection(
$this->_constructPdoDsn($params),
$username,
......@@ -49,24 +45,20 @@ class Driver implements \Doctrine\DBAL\Driver
*/
private function _constructPdoDsn(array $params)
{
$dsn = 'sqlsrv:server=(';
$dsn = 'sqlsrv:server=';
if (isset($params['host'])) {
$dsn .= $params['host'];
}
$dsn .= ')';
if (stripos($dsn, '\sqlexpress') !== false)
{
$dsn = str_ireplace('\sqlexpress', '', $dsn);
$dsn .= '\sqlexpress';
}
$dsn = str_ireplace('localhost', 'local', $dsn);
if (isset($params['port']) && !empty($params['port'])) {
$dsn .= ',' . $params['port'];
}
if (isset($params['dbname'])) {
$dsn .= ';Database=' . $params['dbname'];
}
return $dsn;
}
......
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