Skip to content

Commit

Permalink
Revert "Initial changes to support SQL Server on Linux"
Browse files Browse the repository at this point in the history
DBLIB is a poop drive with tons of bugs.
Based on other comments on GitHub, this driver will not be supported.

This reverts commit 42fae60.
  • Loading branch information
jrbasso committed Jan 14, 2014
1 parent d0dca54 commit 81c1aa4
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions Cake/Database/Driver/Sqlserver.php
Expand Up @@ -61,17 +61,12 @@ public function connect() {
$config['flags'][PDO::SQLSRV_ATTR_ENCODING] = $config['encoding'];
}
if (empty($config['dsn'])) {
if ($this->pdoDriverName() === 'sqlsrv') {
$config['dsn'] = "sqlsrv:Server={$config['host']};Database={$config['database']}";
} else {
$config['dsn'] = "dblib:host={$config['host']};dbname={$config['database']}";
}
$config['dsn'] = "sqlsrv:Server={$config['host']};Database={$config['database']}";
}

$this->_connect($config);

$connection = $this->connection();
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (!empty($config['init'])) {
foreach ((array)$config['init'] as $command) {
$connection->exec($command);
Expand All @@ -85,34 +80,14 @@ public function connect() {
return true;
}

/**
* Establishes a connection to the databse server
*
* @param array $config configuration to be used for creating connection
* @return boolean true on success
*/
protected function _connect(array $config) {
if ($this->pdoDriverName() !== 'sqlsrv') {
$connection = new PDO($config['dsn'], $config['login'], $config['password']);
} else {
$connection = new PDO($config['dsn'], $config['login'], $config['password'], $config['flags']);
}
$this->connection($connection);
return true;
}

/**
* Returns whether php is able to use this driver for connecting to database
*
* @return boolean true if it is valid to use this driver
*/

public function enabled() {
return in_array($this->pdoDriverName(), PDO::getAvailableDrivers());
}

protected function pdoDriverName() {
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? 'sqlsrv' : 'dblib';
return in_array('sqlsrv', PDO::getAvailableDrivers());
}

}

0 comments on commit 81c1aa4

Please sign in to comment.