Added pdo_dblib as a driver for MSSQL (as native MSSQL driver does not exist for PHP7)

This commit is contained in:
Charles Wu 2016-10-10 16:47:16 -07:00 committed by Jakub Vrana
parent 3fa1eadf2c
commit 73690164b7
2 changed files with 16 additions and 3 deletions

View file

@ -8,7 +8,7 @@
$drivers["mssql"] = "MS SQL";
if (isset($_GET["mssql"])) {
$possible_drivers = array("SQLSRV", "MSSQL");
$possible_drivers = array("SQLSRV", "MSSQL", "PDO_DBLIB");
define("DRIVER", "mssql");
if (extension_loaded("sqlsrv")) {
class Min_DB {
@ -234,8 +234,21 @@ if (isset($_GET["mssql"])) {
}
}
}
} elseif (extension_loaded("pdo_dblib")) {
class Min_DB extends Min_PDO {
var $extension = "PDO_DBLIB";
function connect($server, $username, $password) {
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)), $username, $password);
return true;
}
function select_db($database) {
// database selection is separated from the connection so dbname in DSN can't be used
return $this->query("USE " . idf_escape($database));
}
}
}
class Min_Driver extends Min_SQL {

View file

@ -19,7 +19,7 @@ if (extension_loaded('pdo')) {
auth_error($ex->getMessage());
}
$this->setAttribute(13, array('Min_PDOStatement')); // 13 - PDO::ATTR_STATEMENT_CLASS
$this->server_info = $this->getAttribute(4); // 4 - PDO::ATTR_SERVER_VERSION
$this->server_info = @$this->getAttribute(4); // 4 - PDO::ATTR_SERVER_VERSION
}
/*abstract function select_db($database);*/