]> git.joonet.de Git - adminer.git/commitdiff
Added pdo_dblib as a driver for MSSQL (as native MSSQL driver does not exist for...
authorCharles Wu <cwu@wu-pc.com>
Mon, 10 Oct 2016 23:47:16 +0000 (16:47 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sat, 18 Feb 2017 16:35:36 +0000 (17:35 +0100)
adminer/drivers/mssql.inc.php
adminer/include/pdo.inc.php

index 2535c8bfb462ee4d5a7771e2aaba9a8aa143751d..6759004399b1c21a86f0713c18dd0776f542b625 100644 (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 {
index b87eed6d9d87dab48abac012ba98579203c4332f..251b90384a3fb8475554ef51e7ff20d76888f756 100644 (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);*/