]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Remove support for SQLite version 2
authorJakub Vrana <jakub@vrana.cz>
Wed, 26 Feb 2025 11:10:09 +0000 (12:10 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 26 Feb 2025 11:20:37 +0000 (12:20 +0100)
adminer/drivers/sqlite.inc.php
adminer/include/version.inc.php
changes.txt

index bd2921f7df4d8810981bd0dd48ac39f351e73396..ec97e4f0e572781ca27ba5ab7eca43891080dd72 100644 (file)
 <?php
-$drivers["sqlite"] = "SQLite 3";
-$drivers["sqlite2"] = "SQLite 2";
+$drivers["sqlite"] = "SQLite";
 
-if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
-       define("DRIVER", (isset($_GET["sqlite"]) ? "sqlite" : "sqlite2"));
-       if (class_exists(isset($_GET["sqlite"]) ? "SQLite3" : "SQLiteDatabase")) {
-               if (isset($_GET["sqlite"])) {
+if (isset($_GET["sqlite"])) {
+       define("DRIVER", "sqlite");
+       if (class_exists("SQLite3")) {
 
-                       class Min_SQLite {
-                               var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error, $_link;
+               class Min_SQLite {
+                       var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error, $_link;
 
-                               function __construct($filename) {
-                                       $this->_link = new SQLite3($filename);
-                                       $version = $this->_link->version();
-                                       $this->server_info = $version["versionString"];
-                               }
-
-                               function query($query) {
-                                       $result = @$this->_link->query($query);
-                                       $this->error = "";
-                                       if (!$result) {
-                                               $this->errno = $this->_link->lastErrorCode();
-                                               $this->error = $this->_link->lastErrorMsg();
-                                               return false;
-                                       } elseif ($result->numColumns()) {
-                                               return new Min_Result($result);
-                                       }
-                                       $this->affected_rows = $this->_link->changes();
-                                       return true;
-                               }
-
-                               function quote($string) {
-                                       return (is_utf8($string)
-                                               ? "'" . $this->_link->escapeString($string) . "'"
-                                               : "x'" . reset(unpack('H*', $string)) . "'"
-                                       );
-                               }
-
-                               function store_result() {
-                                       return $this->_result;
-                               }
-
-                               function result($query, $field = 0) {
-                                       $result = $this->query($query);
-                                       if (!is_object($result)) {
-                                               return false;
-                                       }
-                                       $row = $result->_result->fetchArray();
-                                       return $row ? $row[$field] : false;
-                               }
-                       }
-
-                       class Min_Result {
-                               var $_result, $_offset = 0, $num_rows;
-
-                               function __construct($result) {
-                                       $this->_result = $result;
-                               }
-
-                               function fetch_assoc() {
-                                       return $this->_result->fetchArray(SQLITE3_ASSOC);
-                               }
-
-                               function fetch_row() {
-                                       return $this->_result->fetchArray(SQLITE3_NUM);
-                               }
-
-                               function fetch_field() {
-                                       $column = $this->_offset++;
-                                       $type = $this->_result->columnType($column);
-                                       return (object) array(
-                                               "name" => $this->_result->columnName($column),
-                                               "type" => $type,
-                                               "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
-                                       );
-                               }
-
-                               function __desctruct() {
-                                       return $this->_result->finalize();
-                               }
+                       function __construct($filename) {
+                               $this->_link = new SQLite3($filename);
+                               $version = $this->_link->version();
+                               $this->server_info = $version["versionString"];
                        }
 
-               } else {
-
-                       class Min_SQLite {
-                               var $extension = "SQLite", $server_info, $affected_rows, $error, $_link;
-
-                               function __construct($filename) {
-                                       $this->server_info = sqlite_libversion();
-                                       $this->_link = new SQLiteDatabase($filename);
-                               }
-
-                               function query($query, $unbuffered = false) {
-                                       $method = ($unbuffered ? "unbufferedQuery" : "query");
-                                       $result = @$this->_link->$method($query, SQLITE_BOTH, $error);
-                                       $this->error = "";
-                                       if (!$result) {
-                                               $this->error = $error;
-                                               return false;
-                                       } elseif ($result === true) {
-                                               $this->affected_rows = $this->changes();
-                                               return true;
-                                       }
+                       function query($query) {
+                               $result = @$this->_link->query($query);
+                               $this->error = "";
+                               if (!$result) {
+                                       $this->errno = $this->_link->lastErrorCode();
+                                       $this->error = $this->_link->lastErrorMsg();
+                                       return false;
+                               } elseif ($result->numColumns()) {
                                        return new Min_Result($result);
                                }
+                               $this->affected_rows = $this->_link->changes();
+                               return true;
+                       }
 
-                               function quote($string) {
-                                       return "'" . sqlite_escape_string($string) . "'";
-                               }
+                       function quote($string) {
+                               return (is_utf8($string)
+                                       ? "'" . $this->_link->escapeString($string) . "'"
+                                       : "x'" . reset(unpack('H*', $string)) . "'"
+                               );
+                       }
 
-                               function store_result() {
-                                       return $this->_result;
-                               }
+                       function store_result() {
+                               return $this->_result;
+                       }
 
-                               function result($query, $field = 0) {
-                                       $result = $this->query($query);
-                                       if (!is_object($result)) {
-                                               return false;
-                                       }
-                                       $row = $result->_result->fetch();
-                                       return $row[$field];
+                       function result($query, $field = 0) {
+                               $result = $this->query($query);
+                               if (!is_object($result)) {
+                                       return false;
                                }
+                               $row = $result->_result->fetchArray();
+                               return $row ? $row[$field] : false;
                        }
+               }
 
-                       class Min_Result {
-                               var $_result, $_offset = 0, $num_rows;
-
-                               function __construct($result) {
-                                       $this->_result = $result;
-                                       if (method_exists($result, 'numRows')) { // not available in unbuffered query
-                                               $this->num_rows = $result->numRows();
-                                       }
-                               }
+               class Min_Result {
+                       var $_result, $_offset = 0, $num_rows;
 
-                               function fetch_assoc() {
-                                       $row = $this->_result->fetch(SQLITE_ASSOC);
-                                       if (!$row) {
-                                               return false;
-                                       }
-                                       $return = array();
-                                       foreach ($row as $key => $val) {
-                                               $return[idf_unescape($key)] = $val;
-                                       }
-                                       return $return;
-                               }
+                       function __construct($result) {
+                               $this->_result = $result;
+                       }
 
-                               function fetch_row() {
-                                       return $this->_result->fetch(SQLITE_NUM);
-                               }
+                       function fetch_assoc() {
+                               return $this->_result->fetchArray(SQLITE3_ASSOC);
+                       }
 
-                               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]));
-                                       }
-                                       return (object) array(
-                                               "name" => $name,
-                                               "orgname" => $name,
-                                               "orgtable" => $table,
-                                       );
-                               }
+                       function fetch_row() {
+                               return $this->_result->fetchArray(SQLITE3_NUM);
+                       }
 
+                       function fetch_field() {
+                               $column = $this->_offset++;
+                               $type = $this->_result->columnType($column);
+                               return (object) array(
+                                       "name" => $this->_result->columnName($column),
+                                       "type" => $type,
+                                       "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
+                               );
                        }
 
+                       function __desctruct() {
+                               return $this->_result->finalize();
+                       }
                }
 
        } elseif (extension_loaded("pdo_sqlite")) {
@@ -400,7 +312,6 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                $return = array();
                foreach (get_rows("PRAGMA foreign_key_list(" . table($table) . ")") as $row) {
                        $foreign_key = &$return[$row["id"]];
-                       //! idf_unescape in SQLite2
                        if (!$foreign_key) {
                                $foreign_key = $row;
                        }
@@ -816,7 +727,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        function driver_config() {
                $types = array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0);
                return array(
-                       'possible_drivers' => array((isset($_GET["sqlite"]) ? "SQLite3" : "SQLite"), "PDO_SQLite"),
+                       'possible_drivers' => array("SQLite3", "PDO_SQLite"),
                        'jush' => "sqlite",
                        'types' => $types,
                        'structured_types' => array_keys($types),
index cdf0d7d17e276f80c9343acf43b73dc7556a7eed..835cadf76e02c41322c5d7f42b99e676917ff50d 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$VERSION = "4.17.2-dev";
+$VERSION = "4.18.0-dev";
index c36a62221676c815184df1a870cfbba2b77f90d2..fac9152550ff2c8c258144a7ae0bd08c93ab6b19 100644 (file)
@@ -1,7 +1,8 @@
-Adminer-4.17.2-dev:
+Adminer-4.18.0-dev:
 SQLite: Support CHECK constraint
 SQLite: Add command Check tables
 SQLite: Display all rows of variable values
+SQLite: Remove support for SQLite version 2
 MongoDB: Remove support for deprecated extension mongo
 
 Adminer-4.17.1 (released 2025-02-25):