]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Read information about collation
authorJakub Vrana <jakub@vrana.cz>
Wed, 28 Aug 2013 15:54:23 +0000 (08:54 -0700)
committerJakub Vrana <jakub@vrana.cz>
Wed, 28 Aug 2013 15:54:23 +0000 (08:54 -0700)
adminer/drivers/sqlite.inc.php

index e2522e5d311f1eb5ffe1292b30056eabb1303ef0..51ccf2b160ae775092eb47d0c0d1393cf7533831 100644 (file)
@@ -291,6 +291,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        }
 
        function fields($table) {
+               global $connection;
                $return = array();
                $primary = "";
                foreach (get_rows("PRAGMA table_info(" . table($table) . ")") as $row) {
@@ -315,6 +316,14 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                                $primary = $name;
                        }
                }
+               $sql = $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
+               preg_match_all('~(("[^"]*+")+|[a-z0-9_]+)\s+text\s+COLLATE\s+(\'[^\']+\'|\S+)~i', $sql, $matches, PREG_SET_ORDER);
+               foreach ($matches as $match) {
+                       $name = str_replace('""', '"', preg_replace('~^"|"$~', '', $match[1]));
+                       if ($return[$name]) {
+                               $return[$name]["collation"] = trim($match[3], "'");
+                       }
+               }
                return $return;
        }