From a2443670f8671abcc9c09c7c34f699da384b35fd Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 29 Oct 2010 15:24:06 +0200 Subject: [PATCH] Always display all drivers (bug #3097666) --- adminer/drivers/mssql.inc.php | 7 +- adminer/drivers/mysql.inc.php | 8 +- adminer/drivers/oracle.inc.php | 7 +- adminer/drivers/pgsql.inc.php | 7 +- adminer/drivers/sqlite.inc.php | 132 ++++++++++++++++----------------- adminer/include/auth.inc.php | 13 ++-- adminer/include/pdo.inc.php | 1 - changes.txt | 1 + 8 files changed, 78 insertions(+), 98 deletions(-) diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index 11f15b54..a604fcfa 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -5,13 +5,10 @@ * @author Jakub Vrana */ -$possible_drivers[] = "SQLSRV"; -$possible_drivers[] = "MSSQL"; -if (extension_loaded("sqlsrv") || extension_loaded("mssql")) { - $drivers["mssql"] = "MS SQL"; -} +$drivers["mssql"] = "MS SQL"; if (isset($_GET["mssql"])) { + $possible_drivers = array("SQLSRV", "MSSQL"); define("DRIVER", "mssql"); if (extension_loaded("sqlsrv")) { class Min_DB { diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index cc0fd66e..5720cabc 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -1,12 +1,8 @@ "MySQL") + $drivers; -} +$drivers = array("server" => "MySQL") + $drivers; if (!defined("DRIVER")) { + $possible_drivers = array("MySQLi", "MySQL", "PDO_MySQL"); define("DRIVER", "server"); // server - backwards compatibility // MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable if (extension_loaded("mysqli")) { diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index cbdb61d5..5d2488b0 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -1,11 +1,8 @@ server_info = sqlite_libversion(); - $this->_link = new SQLiteDatabase($filename); + $this->_link = new SQLite3($filename); + $version = $this->_link->version(); + $this->server_info = $version["versionString"]; } - function query($query, $unbuffered = false) { - $method = ($unbuffered ? "unbufferedQuery" : "query"); - $result = @$this->_link->$method($query, SQLITE_BOTH, $error); + function query($query) { + $result = @$this->_link->query($query); if (!$result) { - $this->error = $error; + $this->error = $this->_link->lastErrorMsg(); return false; - } elseif ($result === true) { - $this->affected_rows = $this->changes(); - return true; + } elseif ($result->numColumns()) { + return new Min_Result($result); } - return new Min_Result($result); + $this->affected_rows = $this->_link->changes(); + return true; } function quote($string) { - return "'" . sqlite_escape_string($string) . "'"; + return "'" . $this->_link->escapeString($string) . "'"; } function store_result() { @@ -48,7 +42,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { if (!is_object($result)) { return false; } - $row = $result->_result->fetch(); + $row = $result->_result->fetchArray(); return $row[$field]; } } @@ -58,68 +52,56 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { function Min_Result($result) { $this->_result = $result; - if (method_exists($result, 'numRows')) { // not available in unbuffered query - $this->num_rows = $result->numRows(); - } } function fetch_assoc() { - $row = $this->_result->fetch(SQLITE_ASSOC); - if (!$row) { - return false; - } - $return = array(); - foreach ($row as $key => $val) { - $return[($key[0] == '"' ? idf_unescape($key) : $key)] = $val; - } - return $return; + return $this->_result->fetchArray(SQLITE3_ASSOC); } function fetch_row() { - return $this->_result->fetch(SQLITE_NUM); + return $this->_result->fetchArray(SQLITE3_NUM); } function fetch_field() { - $name = $this->_result->fieldName($this->_offset++); - $pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))'; - if (preg_match("~^($pattern\\.)?$pattern\$~", $name, $match)) { - $table = ($match[3] != "" ? $match[3] : idf_unescape($match[2])); - $name = ($match[5] != "" ? $match[5] : idf_unescape($match[4])); - } + $column = $this->_offset++; + $type = $this->_result->columnType($column); return (object) array( - "name" => $name, - "orgname" => $name, - "orgtable" => $table, + "name" => $this->_result->columnName($column), + "type" => $type, + "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary ); } + function __desctruct() { + return $this->_result->finalize(); + } } } else { class Min_SQLite { - var $extension = "SQLite3", $server_info, $affected_rows, $error, $_link; + var $extension = "SQLite", $server_info, $affected_rows, $error, $_link; function Min_SQLite($filename) { - $this->_link = new SQLite3($filename); - $version = $this->_link->version(); - $this->server_info = $version["versionString"]; + $this->server_info = sqlite_libversion(); + $this->_link = new SQLiteDatabase($filename); } - function query($query) { - $result = @$this->_link->query($query); + function query($query, $unbuffered = false) { + $method = ($unbuffered ? "unbufferedQuery" : "query"); + $result = @$this->_link->$method($query, SQLITE_BOTH, $error); if (!$result) { - $this->error = $this->_link->lastErrorMsg(); + $this->error = $error; return false; - } elseif ($result->numColumns()) { - return new Min_Result($result); + } elseif ($result === true) { + $this->affected_rows = $this->changes(); + return true; } - $this->affected_rows = $this->_link->changes(); - return true; + return new Min_Result($result); } function quote($string) { - return "'" . $this->_link->escapeString($string) . "'"; + return "'" . sqlite_escape_string($string) . "'"; } function store_result() { @@ -131,7 +113,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { if (!is_object($result)) { return false; } - $row = $result->_result->fetchArray(); + $row = $result->_result->fetch(); return $row[$field]; } } @@ -141,29 +123,41 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { function Min_Result($result) { $this->_result = $result; + if (method_exists($result, 'numRows')) { // not available in unbuffered query + $this->num_rows = $result->numRows(); + } } function fetch_assoc() { - return $this->_result->fetchArray(SQLITE3_ASSOC); + $row = $this->_result->fetch(SQLITE_ASSOC); + if (!$row) { + return false; + } + $return = array(); + foreach ($row as $key => $val) { + $return[($key[0] == '"' ? idf_unescape($key) : $key)] = $val; + } + return $return; } function fetch_row() { - return $this->_result->fetchArray(SQLITE3_NUM); + return $this->_result->fetch(SQLITE_NUM); } function fetch_field() { - $column = $this->_offset++; - $type = $this->_result->columnType($column); + $name = $this->_result->fieldName($this->_offset++); + $pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))'; + if (preg_match("~^($pattern\\.)?$pattern\$~", $name, $match)) { + $table = ($match[3] != "" ? $match[3] : idf_unescape($match[2])); + $name = ($match[5] != "" ? $match[5] : idf_unescape($match[4])); + } return (object) array( - "name" => $this->_result->columnName($column), - "type" => $type, - "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary + "name" => $name, + "orgname" => $name, + "orgtable" => $table, ); } - function __desctruct() { - return $this->_result->finalize(); - } } } diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 156593bc..09c09da0 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -1,12 +1,6 @@ login($_GET["username"], get_session("pwds"))) { diff --git a/adminer/include/pdo.inc.php b/adminer/include/pdo.inc.php index 2e7be171..9c342e04 100644 --- a/adminer/include/pdo.inc.php +++ b/adminer/include/pdo.inc.php @@ -79,5 +79,4 @@ if (extension_loaded('pdo')) { } } -$possible_drivers = array(); $drivers = array(); diff --git a/changes.txt b/changes.txt index 7b3dad97..77c478f7 100644 --- a/changes.txt +++ b/changes.txt @@ -7,6 +7,7 @@ Link to bookmark SQL command Support for virtual foreign keys Immunity against zend.ze1_compatibility_mode Fix last page with empty result set +Always display all drivers Adminer 3.0.1 (released 2010-10-18): Send the form by Ctrl+Enter in all textareas -- 2.39.5