]> git.joonet.de Git - adminer.git/commitdiff
Rename get_dbh to connection
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 22 Sep 2009 10:51:40 +0000 (10:51 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 22 Sep 2009 10:51:40 +0000 (10:51 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1124 7c3ca157-0c34-0410-bff1-cbf682f78f5c

28 files changed:
adminer/call.inc.php
adminer/create.inc.php
adminer/database.inc.php
adminer/db.inc.php
adminer/download.inc.php
adminer/dump.inc.php
adminer/edit.inc.php
adminer/event.inc.php
adminer/include/adminer.inc.php
adminer/include/auth.inc.php
adminer/include/connect.inc.php
adminer/include/editing.inc.php
adminer/include/export.inc.php
adminer/include/functions.inc.php
adminer/include/mysql.inc.php
adminer/privileges.inc.php
adminer/processlist.inc.php
adminer/select.inc.php
adminer/sql.inc.php
adminer/table.inc.php
adminer/trigger.inc.php
adminer/user.inc.php
adminer/variables.inc.php
changes.txt
editor/include/adminer.inc.php
editor/include/connect.inc.php
editor/include/export.inc.php
todo.txt

index 967af20fde7bd585f0de75ffbe2bfd263d79298d..77464ffa9d66e85fc141f1dbf0c6b8dcae5d8e69 100644 (file)
@@ -23,25 +23,25 @@ if (!$error && $_POST) {
                                $val = "''";
                        }
                        if (isset($out[$key])) {
-                               $dbh->query("SET @" . idf_escape($field["field"]) . " = $val");
+                               $connection->query("SET @" . idf_escape($field["field"]) . " = $val");
                        }
                }
                $call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
        }
-       $result = $dbh->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")");
+       $result = $connection->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")");
        if (!$result) {
-               echo "<p class='error'>" . h($dbh->error) . "\n";
+               echo "<p class='error'>" . h($connection->error) . "\n";
        } else {
                do {
-                       $result = $dbh->store_result();
+                       $result = $connection->store_result();
                        if (is_object($result)) {
                                select($result);
                        } else {
-                               echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $dbh->affected_rows) . "\n";
+                               echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $connection->affected_rows) . "\n";
                        }
-               } while ($dbh->next_result());
+               } while ($connection->next_result());
                if ($out) {
-                       select($dbh->query("SELECT " . implode(", ", $out)));
+                       select($connection->query("SELECT " . implode(", ", $out)));
                }
        }
 }
index 73c4d60a79bd3398f8849167320af1ce8178fb0e..8eb0ea5b5018b9b464e1bd0862288c50210332b4 100644 (file)
@@ -62,9 +62,9 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
                        $orig_field = next($orig_fields);
                }
        }
-       $status = "COMMENT=" . $dbh->quote($_POST["Comment"])
-               . ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $dbh->quote($_POST["Engine"]) : "")
-               . ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $dbh->quote($_POST["Collation"]) : "")
+       $status = "COMMENT=" . $connection->quote($_POST["Comment"])
+               . ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
+               . ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
                . (strlen($_POST["auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["auto_increment"]) : "")
        ;
        if (in_array($_POST["partition_by"], $partition_by)) {
@@ -79,7 +79,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
                        ? " (" . implode(",", $partitions) . "\n)"
                        : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
                );
-       } elseif ($dbh->server_info >= 5.1 && strlen($TABLE)) {
+       } elseif ($connection->server_info >= 5.1 && strlen($TABLE)) {
                $status .= "\nREMOVE PARTITIONING";
        }
        $location = ME . "table=" . urlencode($_POST["name"]);
@@ -94,7 +94,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
 page_header((strlen($TABLE) ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
 
 $engines = array();
-$result = $dbh->query("SHOW ENGINES");
+$result = $connection->query("SHOW ENGINES");
 while ($row = $result->fetch_assoc()) {
        if ($row["Support"] == "YES" || $row["Support"] == "DEFAULT") {
                $engines[] = $row["Engine"];
@@ -123,13 +123,13 @@ if ($_POST) {
                }
                $row["fields"][] = $field;
        }
-       if ($dbh->server_info >= 5.1) {
-               $from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $dbh->quote(DB) . " AND TABLE_NAME = " . $dbh->quote($TABLE);
-               $result = $dbh->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
+       if ($connection->server_info >= 5.1) {
+               $from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $connection->quote(DB) . " AND TABLE_NAME = " . $connection->quote($TABLE);
+               $result = $connection->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
                list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
                $row["partition_names"] = array();
                $row["partition_values"] = array();
-               $result = $dbh->query("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");
+               $result = $connection->query("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");
                while ($row1 = $result->fetch_assoc()) {
                        $row["partition_names"][] = $row1["PARTITION_NAME"];
                        $row["partition_values"][] = $row1["PARTITION_DESCRIPTION"];
@@ -173,7 +173,7 @@ document.write('<label><input type="checkbox"<?php if ($column_comments) { ?> ch
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
-if ($dbh->server_info >= 5.1) {
+if ($connection->server_info >= 5.1) {
        $partition_table = ereg('RANGE|LIST', $row["partition_by"]);
        ?>
 <fieldset><legend><?php echo lang('Partition by'); ?></legend>
index a80c4fd6dad00657cbc845f83ade9df1f07476b2..9d67f1621352bd48776eaac0f0b880ea8af218ff 100644 (file)
@@ -11,14 +11,14 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
                $last = "";
                foreach ($dbs as $db) {
                        if (count($dbs) == 1 || strlen($db)) { // ignore empty lines but always try to create single database
-                               if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE " . $dbh->quote($_POST["collation"]) : ""))) {
+                               if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE " . $connection->quote($_POST["collation"]) : ""))) {
                                        $failed = true;
                                }
                                $last = $db;
                        }
                }
                if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), !strlen(DB), false, $failed)) {
-                       $result = $dbh->query("SHOW TABLES");
+                       $result = $connection->query("SHOW TABLES");
                        while ($row = $result->fetch_row()) {
                                if (!queries("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) {
                                        break;
@@ -34,7 +34,7 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
                if (!$_POST["collation"]) {
                        redirect(substr(ME, 0, -1));
                }
-               query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $dbh->quote($_POST["collation"]), substr(ME, 0, -1), lang('Database has been altered.'));
+               query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $connection->quote($_POST["collation"]), substr(ME, 0, -1), lang('Database has been altered.'));
        }
 }
 
@@ -48,15 +48,15 @@ if ($_POST) {
        $collate = $_POST["collation"];
 } elseif (!strlen(DB)) {
        // propose database name with limited privileges
-       $result = $dbh->query("SHOW GRANTS");
+       $result = $connection->query("SHOW GRANTS");
        while ($row = $result->fetch_row()) {
                if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $row[0], $match) && $match[1]) {
                        $name = stripcslashes(idf_unescape($match[2]));
                        break;
                }
        }
-} elseif (($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape(DB)))) {
-       $create = $dbh->result($result, 1);
+} elseif (($result = $connection->query("SHOW CREATE DATABASE " . idf_escape(DB)))) {
+       $create = $connection->result($result, 1);
        if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
                $collate = $match[1];
        } elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) {
index ee1ad064ce650fd6ec97d2c80845680bceb571a4..6e45de49ea0ecf84498f066caaa5a80e9f0fea5c 100644 (file)
@@ -75,10 +75,10 @@ if (!$table_status) {
        echo "</form>\n";
 }
 
-if ($dbh->server_info >= 5) {
+if ($connection->server_info >= 5) {
        echo '<p><a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
        echo "<h3>" . lang('Routines') . "</h3>\n";
-       $result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $dbh->quote(DB));
+       $result = $connection->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $connection->quote(DB));
        if ($result->num_rows) {
                echo "<table cellspacing='0'>\n";
                while ($row = $result->fetch_assoc()) {
@@ -92,7 +92,7 @@ if ($dbh->server_info >= 5) {
        echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
 }
 
-if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) {
+if ($connection->server_info >= 5.1 && ($result = $connection->query("SHOW EVENTS"))) {
        echo "<h3>" . lang('Events') . "</h3>\n";
        if ($result->num_rows) {
                echo "<table cellspacing='0'>\n";
index 15b1987e786785467d56970f1a746ca11f734ce2..dcf39415270597e3e798b064426d4795c9e6f1bb 100644 (file)
@@ -2,5 +2,5 @@
 $TABLE = $_GET["download"];
 header("Content-Type: application/octet-stream");
 header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
-echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($TABLE) . " WHERE " . where($_GET) . " LIMIT 1"));
+echo $connection->result($connection->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($TABLE) . " WHERE " . where($_GET) . " LIMIT 1"));
 exit; // don't output footer
index 02cdcd87c9a73fdf3e59751d80620ff375bffe9e..a90c44a005f99892d1e1c303153d752c6c0a4826 100644 (file)
@@ -7,7 +7,7 @@ if ($_POST) {
                dump("-- Adminer $VERSION dump
 SET NAMES utf8;
 SET foreign_key_checks = 0;
-SET time_zone = " . $dbh->quote($dbh->result($dbh->query("SELECT @@time_zone"))) . ";
+SET time_zone = " . $connection->quote($connection->result($connection->query("SELECT @@time_zone"))) . ";
 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
 
 ");
@@ -15,31 +15,31 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
        
        $style = $_POST["db_style"];
        foreach ((strlen(DB) ? array(DB) : (array) $_POST["databases"]) as $db) {
-               if ($dbh->select_db($db)) {
-                       if ($_POST["format"] == "sql" && ereg('CREATE', $style) && ($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape($db)))) {
+               if ($connection->select_db($db)) {
+                       if ($_POST["format"] == "sql" && ereg('CREATE', $style) && ($result = $connection->query("SHOW CREATE DATABASE " . idf_escape($db)))) {
                                if ($style == "DROP+CREATE") {
                                        dump("DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n");
                                }
-                               $create = $dbh->result($result, 1);
+                               $create = $connection->result($result, 1);
                                dump(($style == "CREATE+ALTER" ? preg_replace('~^CREATE DATABASE ~', '\\0IF NOT EXISTS ', $create) : $create) . ";\n");
                        }
                        if ($style && $_POST["format"] == "sql") {
                                dump("USE " . idf_escape($db) . ";\n" . ($style == "CREATE+ALTER" ? "SET @adminer_alter = '';\n" : "") . "\n");
                                $out = "";
-                               if ($dbh->server_info >= 5) {
+                               if ($connection->server_info >= 5) {
                                        foreach (array("FUNCTION", "PROCEDURE") as $routine) {
-                                               $result = $dbh->query("SHOW $routine STATUS WHERE Db = " . $dbh->quote($db));
+                                               $result = $connection->query("SHOW $routine STATUS WHERE Db = " . $connection->quote($db));
                                                while ($row = $result->fetch_assoc()) {
                                                        $out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "")
-                                                       . $dbh->result($dbh->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n";
+                                                       . $connection->result($connection->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n";
                                                }
                                        }
                                }
-                               if ($dbh->server_info >= 5.1) {
-                                       $result = $dbh->query("SHOW EVENTS");
+                               if ($connection->server_info >= 5.1) {
+                                       $result = $connection->query("SHOW EVENTS");
                                        while ($row = $result->fetch_assoc()) {
                                                $out .= ($style != 'DROP+CREATE' ? "DROP EVENT IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "")
-                                               . $dbh->result($dbh->query("SHOW CREATE EVENT " . idf_escape($row["Name"])), 3) . ";;\n\n";
+                                               . $connection->result($connection->query("SHOW CREATE EVENT " . idf_escape($row["Name"])), 3) . ";;\n\n";
                                        }
                                }
                                if ($out) {
@@ -97,11 +97,11 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
                FETCH tables INTO _table_name, _engine, _table_collation, _table_comment;
                IF NOT done THEN
                        CASE _table_name");
-                               $result = $dbh->query($query);
+                               $result = $connection->query($query);
                                while ($row = $result->fetch_assoc()) {
-                                       $comment = $dbh->quote($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
+                                       $comment = $connection->quote($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
                                        dump("
-                               WHEN " . $dbh->quote($row["TABLE_NAME"]) . " THEN
+                               WHEN " . $connection->quote($row["TABLE_NAME"]) . " THEN
                                        " . (isset($row["ENGINE"]) ? "IF _engine != '$row[ENGINE]' OR _table_collation != '$row[TABLE_COLLATION]' OR _table_comment != $comment THEN
                                                ALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE=$row[ENGINE] COLLATE=$row[TABLE_COLLATION] COMMENT=$comment;
                                        END IF" : "BEGIN END") . ";");
@@ -137,7 +137,7 @@ page_header(lang('Export'), "", (strlen($_GET["export"]) ? array("table" => $_GE
 $db_style = array('', 'USE', 'DROP+CREATE', 'CREATE');
 $table_style = array('', 'DROP+CREATE', 'CREATE');
 $data_style = array('', 'TRUNCATE+INSERT', 'INSERT', 'INSERT+UPDATE');
-if ($dbh->server_info >= 5) {
+if ($connection->server_info >= 5) {
        $db_style[] = 'CREATE+ALTER';
        $table_style[] = 'CREATE+ALTER';
 }
index 6c7908287ad34299a9dd65b159cce58c7df624f5..23d39986803cba193ae6c5dd12322aa95acfa304 100644 (file)
@@ -56,7 +56,7 @@ if ($_POST["save"]) {
        }
        $row = array();
        if ($select) {
-               $result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1"));
+               $result = $connection->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1"));
                $row = $result->fetch_assoc();
        }
 }
index a9c37563022d48e87969626e22d68e0e46cb478f..e00cfc50d6ab6758320444ed27c2e97d6e62c1b3 100644 (file)
@@ -8,17 +8,17 @@ if ($_POST && !$error) {
                query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
        } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
                $schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
-                       ? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
-                       . ($_POST["STARTS"] ? " STARTS " . $dbh->quote($_POST["STARTS"]) : "")
-                       . ($_POST["ENDS"] ? " ENDS " . $dbh->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
-                       : "AT " . $dbh->quote($_POST["STARTS"])
+                       ? "EVERY " . $connection->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
+                       . ($_POST["STARTS"] ? " STARTS " . $connection->quote($_POST["STARTS"]) : "")
+                       . ($_POST["ENDS"] ? " ENDS " . $connection->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
+                       : "AT " . $connection->quote($_POST["STARTS"])
                        ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
                ;
                query_redirect((strlen($EVENT)
                        ? "ALTER EVENT " . idf_escape($EVENT) . $schedule
                        . ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
                        : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
-                       ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"])
+                       ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $connection->quote($_POST["EVENT_COMMENT"])
                        . " DO\n$_POST[EVENT_DEFINITION]"
                , substr(ME, 0, -1), (strlen($EVENT) ? lang('Event has been altered.') : lang('Event has been created.')));
        }
@@ -30,7 +30,7 @@ $row = array();
 if ($_POST) {
        $row = $_POST;
 } elseif (strlen($EVENT)) {
-       $result = $dbh->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $dbh->quote(DB) . " AND EVENT_NAME = " . $dbh->quote($EVENT));
+       $result = $connection->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $connection->quote(DB) . " AND EVENT_NAME = " . $connection->quote($EVENT));
        $row = $result->fetch_assoc();
 }
 ?>
index da2e2a0b140a16a53f027d83a35931eb4d7432d2..6d1cc457662df5dfa1771c8f1398df06264f962c 100644 (file)
@@ -278,11 +278,11 @@ class Adminer {
        * @return array expressions to join by AND
        */
        function selectSearchProcess($fields, $indexes) {
-               global $dbh;
+               global $connection;
                $return = array();
                foreach ($indexes as $i => $index) {
                        if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) {
-                               $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $dbh->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
+                               $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $connection->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
                        }
                }
                foreach ((array) $_GET["where"] as $val) {
@@ -404,9 +404,9 @@ class Adminer {
        * @return string expression to use in a query
        */
        function processInput($field, $value, $function = "") {
-               global $dbh;
+               global $connection;
                $name = $field["field"];
-               $return = $dbh->quote($value);
+               $return = $connection->quote($value);
                if (ereg('^(now|uuid)$', $function)) {
                        $return = "$function()";
                } elseif (ereg('^[+-]$', $function)) {
@@ -470,9 +470,9 @@ class Adminer {
        * @return null
        */
        function printTables($missing) {
-               global $dbh;
-               if ($missing != "db" && strlen(DB) && $dbh->select_db(DB)) {
-                       $result = $dbh->query("SHOW TABLES");
+               global $connection;
+               if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
+                       $result = $connection->query("SHOW TABLES");
                        if (!$result->num_rows) {
                                echo "<p class='message'>" . lang('No tables.') . "\n";
                        } else {
index ce5eadd7a7edd82eb3a23731699a9100fc7a9f3f..e70869372470109907f549ce29d9639a0ffb38ca 100644 (file)
@@ -31,10 +31,10 @@ if (isset($_POST["server"])) {
 }
 
 function auth_error($exception = null) {
-       global $ignore, $dbh, $adminer;
+       global $ignore, $connection, $adminer;
        $username = $_SESSION["usernames"][$_GET["server"]];
        unset($_SESSION["usernames"][$_GET["server"]]);
-       page_header(lang('Login'), (isset($username) ? h($exception ? $exception->getMessage() : (is_string($dbh) ? $dbh : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Session support must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
+       page_header(lang('Login'), (isset($username) ? h($exception ? $exception->getMessage() : (is_string($connection) ? $connection : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Session support must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
        echo "<form action='' method='post'>\n";
        $adminer->loginForm($username);
        echo "<p>\n";
@@ -50,8 +50,8 @@ $username = &$_SESSION["usernames"][$_GET["server"]];
 if (!isset($username)) {
        $username = $_GET["username"]; // default username can be passed in URL
 }
-$dbh = (isset($username) ? connect() : '');
-if (is_string($dbh) || !$adminer->login($username, $_SESSION["passwords"][$_GET["server"]])) {
+$connection = (isset($username) ? connect() : '');
+if (is_string($connection) || !$adminer->login($username, $_SESSION["passwords"][$_GET["server"]])) {
        auth_error();
        exit;
 }
index 550d31a4f2b1d54139f92cfe043e444d00b452f5..d772208b29b07cccc1caa60051a9363b016116f0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 function connect_error() {
-       global $dbh, $VERSION;
+       global $connection, $VERSION;
        if (strlen(DB)) {
                page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), false);
        } else {
@@ -13,13 +13,13 @@ function connect_error() {
                ) as $key => $val) {
                        echo "<p><a href='" . h(ME) . "$key='>$val</a>\n";
                }
-               echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($dbh->server_info < 4.1 ? " class='binary'" : "") . ">$dbh->server_info</b>", "<b>$dbh->extension</b>") . "\n";
-               echo "<p>" . lang('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n";
+               echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($connection->server_info < 4.1 ? " class='binary'" : "") . ">$connection->server_info</b>", "<b>$connection->extension</b>") . "\n";
+               echo "<p>" . lang('Logged as: %s', "<b>" . h($connection->result($connection->query("SELECT USER()"))) . "</b>") . "\n";
        }
        page_footer("db");
 }
 
-if (!(strlen(DB) ? $dbh->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) {
+if (!(strlen(DB) ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) {
        if (strlen(DB)) {
                unset($_SESSION["databases"][$_GET["server"]]);
        }
index 77c9dffc407a1521c30c9b0ed501f886e5f0a1c4..7355f0b146f7f3c0a24eae7d9a3615d5fa8e0e33 100644 (file)
@@ -4,7 +4,7 @@
 * @param Min_DB connection to examine indexes
 * @return null
 */
-function select($result, $dbh2 = null) {
+function select($result, $connection2 = null) {
        if (!$result->num_rows) {
                echo "<p class='message'>" . lang('No rows.') . "\n";
        } else {
@@ -24,7 +24,7 @@ function select($result, $dbh2 = null) {
                                                if (!isset($indexes[$field->orgtable])) {
                                                        // find primary key in each table
                                                        $indexes[$field->orgtable] = array();
-                                                       foreach (indexes($field->orgtable, $dbh2) as $index) {
+                                                       foreach (indexes($field->orgtable, $connection2) as $index) {
                                                                if ($index["type"] == "PRIMARY") {
                                                                        $indexes[$field->orgtable] = array_flip($index["columns"]);
                                                                        break;
@@ -112,21 +112,21 @@ function process_length($length) {
 }
 
 function process_type($field, $collate = "COLLATE") {
-       global $dbh, $enum_length, $unsigned;
+       global $connection, $enum_length, $unsigned;
        return " $field[type]"
                . ($field["length"] && !ereg('^date|time$', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "")
                . (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
-               . (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . $dbh->quote($field["collation"]) : "")
+               . (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . $connection->quote($field["collation"]) : "")
        ;
 }
 
 function process_field($field, $type_field) {
-       global $dbh;
+       global $connection;
        $default = $field["default"] . ($field["on_update"] ? " ON UPDATE $field[on_update]" : "");
        return idf_escape($field["field"]) . process_type($type_field)
                . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
-               . (!isset($field["default"]) || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $default) ? $default : $dbh->quote($default)))
-               . " COMMENT " . $dbh->quote($field["comment"])
+               . (!isset($field["default"]) || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $default) ? $default : $connection->quote($default)))
+               . " COMMENT " . $connection->quote($field["comment"])
        ;
 }
 
@@ -233,11 +233,11 @@ function normalize_enum($match) {
 }
 
 function routine($name, $type) {
-       global $dbh, $enum_length, $inout, $types;
+       global $connection, $enum_length, $inout, $types;
        $aliases = array("bit" => "tinyint", "bool" => "tinyint", "boolean" => "tinyint", "integer" => "int", "double precision" => "float", "real" => "float", "dec" => "decimal", "numeric" => "decimal", "fixed" => "decimal", "national char" => "char", "national varchar" => "varchar");
        $type_pattern = "(" . implode("|", array_keys($types + $aliases)) . ")(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
        $pattern = "\\s*(" . ($type == "FUNCTION" ? "" : implode("|", $inout)) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern";
-       $create = $dbh->result($dbh->query("SHOW CREATE $type " . idf_escape($name)), 2);
+       $create = $connection->result($connection->query("SHOW CREATE $type " . idf_escape($name)), 2);
        preg_match("~\\(((?:$pattern\\s*,?)*)\\)" . ($type == "FUNCTION" ? "\\s*RETURNS\\s+$type_pattern" : "") . "\\s*(.*)~is", $create, $match);
        $fields = array();
        preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER);
index 5a83bb2f1592aa3b8dcaffccedb9f72547c2ab3b..3d6e2672c0a3e9982bff915f7af18672ed1885b4 100644 (file)
@@ -10,9 +10,9 @@ function tar_file($filename, $contents) {
 }
 
 function dump_triggers($table, $style) {
-       global $dbh;
-       if ($_POST["format"] == "sql" && $style && $dbh->server_info >= 5) {
-               $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($table, "%_")));
+       global $connection;
+       if ($_POST["format"] == "sql" && $style && $connection->server_info >= 5) {
+               $result = $connection->query("SHOW TRIGGERS LIKE " . $connection->quote(addcslashes($table, "%_")));
                if ($result->num_rows) {
                        $s = "\nDELIMITER ;;\n";
                        while ($row = $result->fetch_assoc()) {
@@ -25,24 +25,24 @@ function dump_triggers($table, $style) {
 }
 
 function dump_table($table, $style, $is_view = false) {
-       global $dbh;
+       global $connection;
        if ($_POST["format"] == "csv") {
                dump("\xef\xbb\xbf"); // UTF-8 byte order mark
                if ($style) {
                        dump_csv(array_keys(fields($table)));
                }
        } elseif ($style) {
-               $result = $dbh->query("SHOW CREATE TABLE " . idf_escape($table));
+               $result = $connection->query("SHOW CREATE TABLE " . idf_escape($table));
                if ($result) {
                        if ($style == "DROP+CREATE") {
                                dump("DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . idf_escape($table) . ";\n");
                        }
-                       $create = $dbh->result($result, 1);
+                       $create = $connection->result($result, 1);
                        dump(($style != "CREATE+ALTER" ? $create : ($is_view ? substr_replace($create, " OR REPLACE", 6, 0) : substr_replace($create, " IF NOT EXISTS", 12, 0))) . ";\n\n");
                }
                if ($style == "CREATE+ALTER" && !$is_view) {
                        // create procedure which iterates over original columns and adds new and removes old
-                       $query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . $dbh->quote($table) . " ORDER BY ORDINAL_POSITION";
+                       $query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . $connection->quote($table) . " ORDER BY ORDINAL_POSITION";
                        dump("DELIMITER ;;
 CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
        DECLARE _column_name, _collation_name, _column_type, after varchar(64) DEFAULT '';
@@ -53,18 +53,18 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
        DECLARE done, set_after bool DEFAULT 0;
        DECLARE add_columns text DEFAULT '");
                        $fields = array();
-                       $result = $dbh->query($query);
+                       $result = $connection->query($query);
                        $after = "";
                        while ($row = $result->fetch_assoc()) {
-                               $row["default"] = (isset($row["COLUMN_DEFAULT"]) ? $dbh->quote($row["COLUMN_DEFAULT"]) : "NULL");
-                               $row["after"] = $dbh->quote($after); //! rgt AFTER lft, lft AFTER id doesn't work
+                               $row["default"] = (isset($row["COLUMN_DEFAULT"]) ? $connection->quote($row["COLUMN_DEFAULT"]) : "NULL");
+                               $row["after"] = $connection->quote($after); //! rgt AFTER lft, lft AFTER id doesn't work
                                $row["alter"] = escape_string(idf_escape($row["COLUMN_NAME"])
                                        . " $row[COLUMN_TYPE]"
                                        . ($row["COLLATION_NAME"] ? " COLLATE $row[COLLATION_NAME]" : "")
                                        . (isset($row["COLUMN_DEFAULT"]) ? " DEFAULT $row[default]" : "")
                                        . ($row["IS_NULLABLE"] == "YES" ? "" : " NOT NULL")
                                        . ($row["EXTRA"] ? " $row[EXTRA]" : "")
-                                       . ($row["COLUMN_COMMENT"] ? " COMMENT " . $dbh->quote($row["COLUMN_COMMENT"]) : "")
+                                       . ($row["COLUMN_COMMENT"] ? " COMMENT " . $connection->quote($row["COLUMN_COMMENT"]) : "")
                                        . ($after ? " AFTER " . idf_escape($after) : " FIRST")
                                );
                                dump(", ADD $row[alter]");
@@ -83,9 +83,9 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
                        CASE _column_name");
                        foreach ($fields as $row) {
                                dump("
-                               WHEN " . $dbh->quote($row["COLUMN_NAME"]) . " THEN
+                               WHEN " . $connection->quote($row["COLUMN_NAME"]) . " THEN
                                        SET add_columns = REPLACE(add_columns, ', ADD $row[alter]', '');
-                                       IF NOT (_column_default <=> $row[default]) OR _is_nullable != '$row[IS_NULLABLE]' OR _collation_name != '$row[COLLATION_NAME]' OR _column_type != '$row[COLUMN_TYPE]' OR _extra != '$row[EXTRA]' OR _column_comment != " . $dbh->quote($row["COLUMN_COMMENT"]) . " OR after != $row[after] THEN
+                                       IF NOT (_column_default <=> $row[default]) OR _is_nullable != '$row[IS_NULLABLE]' OR _collation_name != '$row[COLLATION_NAME]' OR _column_type != '$row[COLUMN_TYPE]' OR _extra != '$row[EXTRA]' OR _column_comment != " . $connection->quote($row["COLUMN_COMMENT"]) . " OR after != $row[after] THEN
                                                SET @alter_table = CONCAT(@alter_table, ', MODIFY $row[alter]');
                                        END IF;"); //! don't replace in comment
                        }
@@ -115,13 +115,13 @@ DROP PROCEDURE adminer_alter;
 }
 
 function dump_data($table, $style, $select = "") {
-       global $dbh, $max_packet;
+       global $connection, $max_packet;
        if ($style) {
                if ($_POST["format"] != "csv" && $style == "TRUNCATE+INSERT") {
                        dump("TRUNCATE " . idf_escape($table) . ";\n");
                }
                $fields = fields($table);
-               $result = $dbh->query(($select ? $select : "SELECT * FROM " . idf_escape($table)), 1); // 1 - MYSQLI_USE_RESULT //! enum and set as numbers, microtime
+               $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)), 1); // 1 - MYSQLI_USE_RESULT //! enum and set as numbers, microtime
                if ($result) {
                        $insert = "";
                        $buffer = "";
@@ -133,7 +133,7 @@ function dump_data($table, $style, $select = "") {
                                                $insert = "INSERT INTO " . idf_escape($table) . " (" . implode(", ", array_map('idf_escape', array_keys($row))) . ") VALUES";
                                        }
                                        foreach ($row as $key => $val) {
-                                               $row[$key] = (isset($val) ? (ereg('int|float|double|decimal', $fields[$key]["type"]) ? $val : $dbh->quote($val)) : "NULL"); //! columns looking like functions
+                                               $row[$key] = (isset($val) ? (ereg('int|float|double|decimal', $fields[$key]["type"]) ? $val : $connection->quote($val)) : "NULL"); //! columns looking like functions
                                        }
                                        $s = implode(",\t", $row);
                                        if ($style == "INSERT+UPDATE") {
index 76bba2a943bc94ad94b573307a308a930456b508..5a4a5b690e47ee557e758b052079c75fcc5c49b6 100644 (file)
@@ -2,10 +2,10 @@
 /** Get database connection
 * @return Min_DB
 */
-function get_dbh() {
-       // can be used in customization, $dbh is minified
-       global $dbh;
-       return $dbh;
+function connection() {
+       // can be used in customization, $connection is minified
+       global $connection;
+       return $connection;
 }
 
 /** Escape database identifier
@@ -87,9 +87,9 @@ function optionlist($options, $selected = null, $use_keys = false) {
 * @return array
 */
 function get_vals($query, $column = 0) {
-       global $dbh;
+       global $connection;
        $return = array();
-       $result = $dbh->query($query);
+       $result = $connection->query($query);
        if ($result) {
                while ($row = $result->fetch_row()) {
                        $return[] = $row[$column];
@@ -130,11 +130,11 @@ function unique_idf($row, $indexes) {
 * @return string
 */
 function where($where) {
-       global $dbh;
+       global $connection;
        $return = array();
        foreach ((array) $where["where"] as $key => $val) {
                $key = bracket_escape($key, "back");
-               $return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " = BINARY " . $dbh->quote($val); //! enum and set, columns looking like functions
+               $return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " = BINARY " . $connection->quote($val); //! enum and set, columns looking like functions
        }
        foreach ((array) $where["null"] as $key) {
                $key = bracket_escape($key, "back");
@@ -194,16 +194,16 @@ function redirect($location, $message = null) {
 * @return bool
 */
 function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
-       global $dbh, $error, $adminer;
+       global $connection, $error, $adminer;
        $sql = "";
        if ($query) {
                $sql = $adminer->messageQuery($query);
        }
        if ($execute) {
-               $failed = !$dbh->query($query);
+               $failed = !$connection->query($query);
        }
        if ($failed) {
-               $error = h($dbh->error) . $sql;
+               $error = h($connection->error) . $sql;
                return false;
        }
        if ($redirect) {
@@ -217,14 +217,14 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
 * @return Min_Result
 */
 function queries($query = null) {
-       global $dbh;
+       global $connection;
        static $queries = array();
        if (!isset($query)) {
                // return executed queries without parameter
                return implode(";\n", $queries);
        }
        $queries[] = $query;
-       return $dbh->query($query);
+       return $connection->query($query);
 }
 
 /** Remove parameter from query string
@@ -413,7 +413,7 @@ function input($field, $value, $function) {
 * @return string
 */
 function process_input($field) {
-       global $dbh, $adminer;
+       global $connection, $adminer;
        $idf = bracket_escape($field["field"]);
        $function = $_POST["function"][$idf];
        $value = $_POST["fields"][$idf];
@@ -430,7 +430,7 @@ function process_input($field) {
                if (!is_string($file)) {
                        return false; //! report errors
                }
-               return "_binary" . $dbh->quote($file);
+               return "_binary" . $connection->quote($file);
        } else {
                return $adminer->processInput($field, $value, $function);
        }
index c896ae7ee8694545ece525bac4e26880fe245982..250db857c429894826bcdd94d611a45a284e85c8 100644 (file)
@@ -145,14 +145,14 @@ if (extension_loaded("mysqli")) {
 */
 function connect() {
        global $adminer;
-       $dbh = new Min_DB;
+       $connection = new Min_DB;
        $credentials = $adminer->credentials();
-       if ($dbh->connect($credentials[0], $credentials[1], $credentials[2])) {
-               $dbh->query("SET SQL_QUOTE_SHOW_CREATE=1");
-               $dbh->query("SET NAMES utf8");
-               return $dbh;
+       if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
+               $connection->query("SET SQL_QUOTE_SHOW_CREATE=1");
+               $connection->query("SET NAMES utf8");
+               return $connection;
        }
-       return $dbh->error;
+       return $connection->error;
 }
 
 /** Get cached list of databases
@@ -177,9 +177,9 @@ function get_databases($flush = true) {
 * @return array
 */
 function table_status($name = "") {
-       global $dbh;
+       global $connection;
        $return = array();
-       $result = $dbh->query("SHOW TABLE STATUS" . (strlen($name) ? " LIKE " . $dbh->quote(addcslashes($name, "%_")) : ""));
+       $result = $connection->query("SHOW TABLE STATUS" . (strlen($name) ? " LIKE " . $connection->quote(addcslashes($name, "%_")) : ""));
        while ($row = $result->fetch_assoc()) {
                if ($row["Engine"] == "InnoDB") {
                        // ignore internal comment, unnecessary since MySQL 5.1.21
@@ -208,9 +208,9 @@ function table_status_referencable() {
 * @return array array($name => array("field" => , "full_type" => , "type" => , "length" => , "unsigned" => , "default" => , "null" => , "auto_increment" => , "on_update" => , "collation" => , "privileges" => , "comment" => , "primary" => ))
 */
 function fields($table) {
-       global $dbh;
+       global $connection;
        $return = array();
-       $result = $dbh->query("SHOW FULL COLUMNS FROM " . idf_escape($table));
+       $result = $connection->query("SHOW FULL COLUMNS FROM " . idf_escape($table));
        if ($result) {
                while ($row = $result->fetch_assoc()) {
                        preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
@@ -239,13 +239,13 @@ function fields($table) {
 * @param string Min_DB to use
 * @return array array($key_name => array("type" => , "columns" => array(), "lengths" => array()))
 */
-function indexes($table, $dbh2 = null) {
-       global $dbh;
-       if (!is_object($dbh2)) { // use the main connection if the separate connection is unavailable
-               $dbh2 = $dbh;
+function indexes($table, $connection2 = null) {
+       global $connection;
+       if (!is_object($connection2)) { // use the main connection if the separate connection is unavailable
+               $connection2 = $connection;
        }
        $return = array();
-       $result = $dbh2->query("SHOW INDEX FROM " . idf_escape($table));
+       $result = $connection2->query("SHOW INDEX FROM " . idf_escape($table));
        if ($result) {
                while ($row = $result->fetch_assoc()) {
                        $return[$row["Key_name"]]["type"] = ($row["Key_name"] == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? "INDEX" : "UNIQUE")));
@@ -261,12 +261,12 @@ function indexes($table, $dbh2 = null) {
 * @return array array($name => array("db" => , "table" => , "source" => array(), "target" => array(), "on_delete" => , "on_update" => ))
 */
 function foreign_keys($table) {
-       global $dbh, $on_actions;
+       global $connection, $on_actions;
        static $pattern = '(?:[^`]|``)+';
        $return = array();
-       $result = $dbh->query("SHOW CREATE TABLE " . idf_escape($table));
+       $result = $connection->query("SHOW CREATE TABLE " . idf_escape($table));
        if ($result) {
-               $create_table = $dbh->result($result, 1);
+               $create_table = $connection->result($result, 1);
                preg_match_all("~CONSTRAINT `($pattern)` FOREIGN KEY \\(((?:`$pattern`,? ?)+)\\) REFERENCES `($pattern)`(?:\\.`($pattern)`)? \\(((?:`$pattern`,? ?)+)\\)(?: ON DELETE (" . implode("|", $on_actions) . "))?(?: ON UPDATE (" . implode("|", $on_actions) . "))?~", $create_table, $matches, PREG_SET_ORDER);
                foreach ($matches as $match) {
                        preg_match_all("~`($pattern)`~", $match[2], $source);
@@ -289,17 +289,17 @@ function foreign_keys($table) {
 * @return array array("select" => )
 */
 function view($name) {
-       global $dbh;
-       return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)* AS ~U', '', $dbh->result($dbh->query("SHOW CREATE VIEW " . idf_escape($name)), 1)));
+       global $connection;
+       return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)* AS ~U', '', $connection->result($connection->query("SHOW CREATE VIEW " . idf_escape($name)), 1)));
 }
 
 /** Get sorted grouped list of collations
 * @return array
 */
 function collations() {
-       global $dbh;
+       global $connection;
        $return = array();
-       $result = $dbh->query("SHOW COLLATION");
+       $result = $connection->query("SHOW COLLATION");
        while ($row = $result->fetch_assoc()) {
                $return[$row["Charset"]][] = $row["Collation"];
        }
@@ -315,8 +315,8 @@ function collations() {
 * @return string
 */
 function escape_string($val) {
-       global $dbh;
-       return substr($dbh->quote($val), 1, -1);
+       global $connection;
+       return substr($connection->quote($val), 1, -1);
 }
 
 /** Find out if database is information_schema
@@ -324,8 +324,8 @@ function escape_string($val) {
 * @return bool
 */
 function information_schema($db) {
-       global $dbh;
-       return ($dbh->server_info >= 5 && $db == "information_schema");
+       global $connection;
+       return ($connection->server_info >= 5 && $db == "information_schema");
 }
 
 // value means maximum unsigned length
index a3b77958d981ec6b9880c5bbaff8a209cfe0ddb0..9642c812fd8fae9e6998b8b0985f9ad962a1f9b9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 page_header(lang('Privileges'));
 
-$result = $dbh->query("SELECT User, Host FROM mysql.user ORDER BY Host, User");
+$result = $connection->query("SELECT User, Host FROM mysql.user ORDER BY Host, User");
 if (!$result) {
        ?>
 <form action=""><p>
@@ -14,7 +14,7 @@ if (!$result) {
 </form>
 <?php
        // list logged user, information_schema.USER_PRIVILEGES lists just the current user too
-       $result = $dbh->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");
+       $result = $connection->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");
 }
 echo "<table cellspacing='0'>\n";
 echo "<thead><tr><th>&nbsp;<th>" . lang('Username') . "<th>" . lang('Server') . "</thead>\n";
index b30640dc6e26bd0853932d5c3faf8dad778dea62..1be05d02380f8446f12863c3aedd76a0bcb71829 100644 (file)
@@ -15,7 +15,7 @@ page_header(lang('Process list'), $error);
 <form action="" method="post">
 <table cellspacing="0" onclick="table_click(event);">
 <?php
-$result = $dbh->query("SHOW PROCESSLIST");
+$result = $connection->query("SHOW PROCESSLIST");
 for ($i=0; $row = $result->fetch_assoc(); $i++) {
        if (!$i) {
                echo "<thead><tr lang='en'><th>&nbsp;<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
index ffeee302a443ca5780ad40c5020d96050ce9359a..e942653729e7df70c80db5b9c2ef2034ceae7570 100644 (file)
@@ -74,7 +74,7 @@ if ($_POST && !$error) {
                        if ($_POST["delete"] || $set) {
                                if ($_POST["all"] || ($primary === array() && $_POST["check"])) {
                                        $result = queries($command . ($_POST["all"] ? ($where ? "\nWHERE " . implode(" AND ", $where) : "") : "\nWHERE $where_check"));
-                                       $affected = $dbh->affected_rows;
+                                       $affected = $connection->affected_rows;
                                } else {
                                        foreach ((array) $_POST["check"] as $val) {
                                                // where is not unique so OR can't be used
@@ -82,7 +82,7 @@ if ($_POST && !$error) {
                                                if (!$result) {
                                                        break;
                                                }
-                                               $affected += $dbh->affected_rows;
+                                               $affected += $connection->affected_rows;
                                        }
                                }
                        }
@@ -103,7 +103,7 @@ if ($_POST && !$error) {
                                } else {
                                        $set = "";
                                        foreach ($matches2[1] as $i => $col) {
-                                               $set .= ", " . idf_escape($cols[$i]) . " = " . (!strlen($col) && $fields[$cols[$i]]["null"] ? "NULL" : $dbh->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
+                                               $set .= ", " . idf_escape($cols[$i]) . " = " . (!strlen($col) && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
                                        }
                                        $set = substr($set, 1);
                                        $result = queries("INSERT INTO " . idf_escape($_GET["select"]) . " SET$set ON DUPLICATE KEY UPDATE$set");
@@ -136,7 +136,7 @@ if (isset($rights["insert"])) {
 $adminer->selectLinks($table_status, $set);
 
 if (!$columns) {
-       echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . h($dbh->error)) . ".\n";
+       echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . h($connection->error)) . ".\n";
 } else {
        echo "<form action='' id='form'>\n";
        echo "<div style='display: none;'>";
@@ -155,9 +155,9 @@ if (!$columns) {
        $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
        echo $adminer->selectQuery($query);
        
-       $result = $dbh->query($query);
+       $result = $connection->query($query);
        if (!$result) {
-               echo "<p class='error'>" . h($dbh->error) . "\n";
+               echo "<p class='error'>" . h($connection->error) . "\n";
        } else {
                $email_fields = array();
                echo "<form action='' method='post' enctype='multipart/form-data'>\n";
@@ -170,7 +170,7 @@ if (!$columns) {
                        }
                        // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
                        $found_rows = (intval($limit) && $group && count($group) < count($select)
-                               ? $dbh->result($dbh->query(" SELECT FOUND_ROWS()")) // space to allow mysql.trace_mode
+                               ? $connection->result($connection->query(" SELECT FOUND_ROWS()")) // space to allow mysql.trace_mode
                                : count($rows)
                        );
                        
@@ -266,7 +266,7 @@ if (!$columns) {
                                // slow with big tables
                                ob_flush();
                                flush();
-                               $found_rows = $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
+                               $found_rows = $connection->result($connection->query("SELECT COUNT(*) FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
                        }
                        echo "<p>";
                        if (intval($limit) && $found_rows > $limit) {
index 1e97a073c5cb04ed7e3dcf71367faa0ee42540d1..68b25601fbe143413741694b451e4d4a1e118c07 100644 (file)
@@ -33,9 +33,9 @@ if (!$error && $_POST) {
                $delimiter = ";";
                $offset = 0;
                $empty = true;
-               $dbh2 = (strlen(DB) ? connect() : null); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
-               if (is_object($dbh2)) {
-                       $dbh2->select_db(DB);
+               $connection2 = (strlen(DB) ? connect() : null); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
+               if (is_object($connection2)) {
+                       $connection2->select_db(DB);
                }
                $explain = 1;
                while (strlen($query)) {
@@ -60,8 +60,8 @@ if (!$error && $_POST) {
                                                flush(); // can take a long time - show the running query
                                                $start = explode(" ", microtime()); // microtime(true) is available since PHP 5
                                                //! don't allow changing of character_set_results, convert encoding of displayed query
-                                               if (!$dbh->multi_query($q)) {
-                                                       echo "<p class='error'>" . lang('Error in query') . ": " . h($dbh->error) . "\n";
+                                               if (!$connection->multi_query($q)) {
+                                                       echo "<p class='error'>" . lang('Error in query') . ": " . h($connection->error) . "\n";
                                                        if ($_POST["error_stops"]) {
                                                                break;
                                                        }
@@ -69,15 +69,15 @@ if (!$error && $_POST) {
                                                        $end = explode(" ", microtime());
                                                        echo "<p class='time'>" . lang('%.3f s', max(0, $end[0] - $start[0] + $end[1] - $start[1])) . "</p>\n";
                                                        do {
-                                                               $result = $dbh->store_result();
+                                                               $result = $connection->store_result();
                                                                if (is_object($result)) {
-                                                                       select($result, $dbh2);
+                                                                       select($result, $connection2);
                                                                        echo "<p>" . lang('%d row(s)', $result->num_rows);
-                                                                       if ($dbh2 && preg_match("~^$space*SELECT$space+~isU", $q)) {
+                                                                       if ($connection2 && preg_match("~^$space*SELECT$space+~isU", $q)) {
                                                                                $id = "explain-$explain";
                                                                                echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>\n";
                                                                                echo "<div id='$id' class='hidden'>\n";
-                                                                               select($dbh2->query("EXPLAIN $q"), $dbh2);
+                                                                               select($connection2->query("EXPLAIN $q"), $connection2);
                                                                                echo "</div>\n";
                                                                                $explain++;
                                                                        }
@@ -85,10 +85,10 @@ if (!$error && $_POST) {
                                                                        if (preg_match("~^$space*$alter_database", $query)) {
                                                                                $databases = null; // clear cache
                                                                        }
-                                                                       echo "<p class='message'>" . lang('Query executed OK, %d row(s) affected.', $dbh->affected_rows) . "\n";
+                                                                       echo "<p class='message'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "\n";
                                                                }
                                                                unset($result); // free resultset
-                                                       } while ($dbh->next_result());
+                                                       } while ($connection->next_result());
                                                }
                                                $query = substr($query, $offset);
                                                $offset = 0;
index f608c681b6ee1b5ecdbe04a2310bd9486444fa1b..dd3f1d11c2e4add5bc6dcbb42e4cce13a22c3da4 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 $TABLE = $_GET["table"];
-$result = $dbh->query("SHOW FULL COLUMNS FROM " . idf_escape($TABLE));
+$result = $connection->query("SHOW FULL COLUMNS FROM " . idf_escape($TABLE));
 if (!$result) {
-       $error = h($dbh->error);
+       $error = h($connection->error);
 }
 $table_status = ($result ? table_status($TABLE) : array());
 
@@ -55,9 +55,9 @@ if ($result) {
                        echo '<p><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
                }
                
-               if ($dbh->server_info >= 5) {
+               if ($connection->server_info >= 5) {
                        echo "<h3>" . lang('Triggers') . "</h3>\n";
-                       $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($TABLE, "%_")));
+                       $result = $connection->query("SHOW TRIGGERS LIKE " . $connection->quote(addcslashes($TABLE, "%_")));
                        if ($result->num_rows) {
                                echo "<table cellspacing='0'>\n";
                                while ($row = $result->fetch_assoc()) {
index 4cb1374795bdd55604a1b14a8225954a1a61ca86..be90d846c6cb1f556c7d36f1cc6ca5554c267efd 100644 (file)
@@ -21,7 +21,7 @@ $row = array("Trigger" => $TABLE . "_bi");
 if ($_POST) {
        $row = $_POST;
 } elseif (strlen($_GET["name"])) {
-       $result = $dbh->query("SHOW TRIGGERS WHERE `Trigger` = " . $dbh->quote($_GET["name"]));
+       $result = $connection->query("SHOW TRIGGERS WHERE `Trigger` = " . $connection->quote($_GET["name"]));
        $row = $result->fetch_assoc();
 }
 ?>
index d7e4ed76f51e4e92244684f2665cbd94bb67faee..163c51bba8b185cf22d2b3b8f6571816d37cd607 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 $USER = $_GET["user"];
 $privileges = array("" => array("All privileges" => ""));
-$result = $dbh->query("SHOW PRIVILEGES");
+$result = $connection->query("SHOW PRIVILEGES");
 while ($row = $result->fetch_assoc()) {
        foreach (explode(",", ($row["Privilege"] == "Grant option" ? "" : $row["Context"])) as $context) {
                $privileges[$context][$row["Privilege"]] = $row["Comment"];
@@ -27,7 +27,7 @@ if ($_POST) {
 }
 $grants = array();
 $old_pass = "";
-if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->quote($USER) . "@" . $dbh->quote($_GET["host"])))) { //! use information_schema for MySQL 5 - column names in column privileges are not escaped
+if (isset($_GET["host"]) && ($result = $connection->query("SHOW GRANTS FOR " . $connection->quote($USER) . "@" . $connection->quote($_GET["host"])))) { //! use information_schema for MySQL 5 - column names in column privileges are not escaped
        while ($row = $result->fetch_row()) {
                if (preg_match('~GRANT (.*) ON (.*) TO ~', $row[0], $match) && preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~', $match[1], $matches, PREG_SET_ORDER)) { //! escape the part between ON and TO
                        foreach ($matches as $val) {
@@ -44,16 +44,16 @@ if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->qu
 }
 
 if ($_POST && !$error) {
-       $old_user = (isset($_GET["host"]) ? $dbh->quote($USER) . "@" . $dbh->quote($_GET["host"]) : "''");
-       $new_user = $dbh->quote($_POST["user"]) . "@" . $dbh->quote($_POST["host"]); // if $_GET["host"] is not set then $new_user is always different
-       $pass = $dbh->quote($_POST["pass"]);
+       $old_user = (isset($_GET["host"]) ? $connection->quote($USER) . "@" . $connection->quote($_GET["host"]) : "''");
+       $new_user = $connection->quote($_POST["user"]) . "@" . $connection->quote($_POST["host"]); // if $_GET["host"] is not set then $new_user is always different
+       $pass = $connection->quote($_POST["pass"]);
        if ($_POST["drop"]) {
                query_redirect("DROP USER $old_user", ME . "privileges=", lang('User has been dropped.'));
        } else {
                if ($old_user == $new_user) {
                        queries("SET PASSWORD FOR $new_user = " . ($_POST["hashed"] ? $pass : "PASSWORD($pass)"));
                } else {
-                       $error = !queries(($dbh->server_info < 5 ? "GRANT USAGE ON *.* TO" : "CREATE USER") . " $new_user IDENTIFIED BY" . ($_POST["hashed"] ? " PASSWORD" : "") . " $pass");
+                       $error = !queries(($connection->server_info < 5 ? "GRANT USAGE ON *.* TO" : "CREATE USER") . " $new_user IDENTIFIED BY" . ($_POST["hashed"] ? " PASSWORD" : "") . " $pass");
                }
                if (!$error) {
                        $revoke = array();
@@ -94,7 +94,7 @@ if ($_POST && !$error) {
                query_redirect(queries(), ME . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error, false, $error);
                if ($old_user != $new_user) {
                        // delete new user in case of an error
-                       $dbh->query("DROP USER $new_user");
+                       $connection->query("DROP USER $new_user");
                }
        }
 }
@@ -105,7 +105,7 @@ if ($_POST) {
        $row = $_POST;
        $grants = $new_grants;
 } else {
-       $row = $_GET + array("host" => $dbh->result($dbh->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"))); // create user on the same domain by default
+       $row = $_GET + array("host" => $connection->result($connection->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"))); // create user on the same domain by default
        $row["pass"] = $old_pass;
        if (strlen($old_pass)) {
                $row["hashed"] = true;
index a977b98609a12d9e5f26b3e193f0f843f7dce44e..127ddc6cc2ff5715669e673d9fdf43f05885548d 100644 (file)
@@ -2,7 +2,7 @@
 page_header(lang('Variables'));
 
 echo "<table cellspacing='0'>\n";
-$result = $dbh->query("SHOW VARIABLES");
+$result = $connection->query("SHOW VARIABLES");
 while ($row = $result->fetch_assoc()) {
        echo "<tr>";
        echo "<th><code class='jush-sqlset'>" . h($row["Variable_name"]) . "</code>";
index 7eb492346c059dac372a2bfbad627bfd7a065620..b0b7b44c56e1a64c401323ebb8fc47ba80d9a3fd 100644 (file)
@@ -1,3 +1,10 @@
+Adminer 2.1.1-dev:
+Display table links above table structure
+Fix removed default in ALTER
+Display whitespace in texts (bug #2858042)
+Move <h1> to $adminer->navigation (customization)
+Rename get_dbh to connection (customization)
+
 Adminer 2.1.0 (released 2009-09-12):
 Edit default values directly in table creation
 Execute SQL file stored on server disk
index 10c7ff66c46fc4521b23aa2c4cca2f74f958b06c..c44cdeb5f8ab8bf2b4fae9037a05cc9bf0235dc4 100644 (file)
@@ -10,10 +10,10 @@ class Adminer {
        }
        
        function database() {
-               global $dbh;
+               global $connection;
                $dbs = get_databases(false);
                return (!$dbs
-                       ? $dbh->result($dbh->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)")) // username without the database list
+                       ? $connection->result($connection->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)")) // username without the database list
                        : $dbs[(information_schema($dbs[0]) ? 1 : 0)] // first available database
                );
        }
@@ -47,13 +47,13 @@ class Adminer {
        }
        
        function backwardKeys($table) {
-               global $dbh;
+               global $connection;
                $return = array();
-               $result = $dbh->query("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
+               $result = $connection->query("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
 FROM information_schema.KEY_COLUMN_USAGE
-WHERE TABLE_SCHEMA = " . $dbh->quote($this->database()) . "
-AND REFERENCED_TABLE_SCHEMA = " . $dbh->quote($this->database()) . "
-AND REFERENCED_TABLE_NAME = " . $dbh->quote($table) . "
+WHERE TABLE_SCHEMA = " . $connection->quote($this->database()) . "
+AND REFERENCED_TABLE_SCHEMA = " . $connection->quote($this->database()) . "
+AND REFERENCED_TABLE_NAME = " . $connection->quote($table) . "
 ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
                if ($result) {
                        while ($row = $result->fetch_assoc()) {
@@ -78,7 +78,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
        function rowDescriptions($rows, $foreignKeys) {
-               global $dbh;
+               global $connection;
                $return = $rows;
                foreach ($rows[0] as $key => $val) {
                        foreach ((array) $foreignKeys[$key] as $foreignKey) {
@@ -89,11 +89,11 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
                                                // find all used ids
                                                $ids = array();
                                                foreach ($rows as $row) {
-                                                       $ids[$row[$key]] = $dbh->quote($row[$key]);
+                                                       $ids[$row[$key]] = $connection->quote($row[$key]);
                                                }
                                                // uses constant number of queries to get the descriptions, join would be complex, multiple queries would be slow
                                                $descriptions = array();
-                                               $result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " WHERE $id IN (" . implode(", ", $ids) . ")");
+                                               $result = $connection->query("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " WHERE $id IN (" . implode(", ", $ids) . ")");
                                                while ($row = $result->fetch_row()) {
                                                        $descriptions[$row[0]] = $row[1];
                                                }
@@ -254,7 +254,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
        function selectEmailProcess($where, $foreignKeys) {
-               global $dbh;
+               global $connection;
                if ($_POST["email_append"]) {
                        return true;
                }
@@ -265,7 +265,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
                                $subject = $_POST["email_subject"];
                                $message = $_POST["email_message"];
                                preg_match_all('~\\{\\$([a-z0-9_]+)\\}~i', "$subject.$message", $matches); // allows {$name} in subject or message
-                               $result = $dbh->query("SELECT DISTINCT $field, " . implode(", ", array_map('idf_escape', array_unique($matches[1]))) . " FROM " . idf_escape($_GET["select"])
+                               $result = $connection->query("SELECT DISTINCT $field, " . implode(", ", array_map('idf_escape', array_unique($matches[1]))) . " FROM " . idf_escape($_GET["select"])
                                        . " WHERE $field IS NOT NULL AND $field != ''"
                                        . ($where ? " AND " . implode(" AND ", $where) : "")
                                        . ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . "))")
@@ -310,15 +310,15 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
        function editInput($table, $field, $attrs, $value) {
-               global $dbh;
+               global $connection;
                $foreign_keys = column_foreign_keys($table);
                foreach ((array) $foreign_keys[$field["field"]] as $foreign_key) {
                        if (count($foreign_key["source"]) == 1) {
                                $id = idf_escape($foreign_key["target"][0]);
                                $name = $this->rowDescription($foreign_key["table"]);
-                               if (strlen($name) && $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big
+                               if (strlen($name) && $connection->result($connection->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big
                                        $return = array("" => "");
-                                       $result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2");
+                                       $result = $connection->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2");
                                        while ($row = $result->fetch_row()) {
                                                $return[$row[0]] = $row[1];
                                        }
@@ -336,11 +336,11 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
        function processInput($field, $value, $function = "") {
-               global $dbh;
+               global $connection;
                if ($function == "now") {
                        return "$function()";
                }
-               $return = $dbh->quote(ereg('date|timestamp', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P<p1>[0-9]+)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\\2>[0-9]{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)
+               $return = $connection->quote(ereg('date|timestamp', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P<p1>[0-9]+)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\\2>[0-9]{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)
                        ? ($match["p1"] ? $match["p1"] : ($match["p2"] < 70 ? 20 : 19) . $match["p2"]) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match)
                        : $value
                );
index 8bc07761a59962a1a9c00863175274c053eb1266..feb69e27eb61d161344b0b28d867d9ffec9ef41b 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$dbh->select_db($adminer->database());
+$connection->select_db($adminer->database());
index 319410a5c14829f9015d90d1563bcdbafe7cb7bc..56ec32e2de1b167c755c18eb80169e7bb6f1db4b 100644 (file)
@@ -4,8 +4,8 @@ function dump_table($table) {
 }
 
 function dump_data($table, $style, $select = "") {
-       global $dbh;
-       $result = $dbh->query(($select ? $select : "SELECT * FROM " . idf_escape($table)));
+       global $connection;
+       $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)));
        if ($result) {
                while ($row = $result->fetch_assoc()) {
                        dump_csv($row);
index 645b6a4c944c5c1d6aa5ec97427993ac70638f9f..b5099835ed99670d2af70ea5131c577d16a418f3 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -11,7 +11,7 @@ IE6 - <label for>
 Offer enum and set items in search - whisperer
 Use event $intervals + microseconds in relative date functions
 ? Column and table names auto-completition in SQL textarea
-? Aliasing of built-in functions can save 7 KB, function minification can save 7 KB, substitution of repetitive $a["a"] can save 4 KB, substitution of $_GET and friends can save 2 KB, JS packer can save 1 KB, not enclosing HTML attribute values can save 1.2 KB
+? Aliasing of built-in functions can save 7 KB, function minification can save 7 KB, substitution of repetitive $a["a"] can save 4 KB, substitution of $_GET and friends can save 2 KB, JS packer can save 1 KB, not enclosing HTML attribute values can save 1.2 KB, replacing \\n by \n can save .3 KB
 ? Branch binary_compile: LZW compression of translations can save 30 KB, LZW compression of all texts can save 11 KB, remove of base64_decode() + using chars 127-255 in minification can save 1 KB
 ? AJAX editing - select page has all data to display edit form