]> git.joonet.de Git - adminer.git/commitdiff
Save bytes
authorJakub Vrana <jakub@vrana.cz>
Sat, 27 Apr 2013 01:54:19 +0000 (18:54 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sat, 27 Apr 2013 02:34:03 +0000 (19:34 -0700)
adminer/dump.inc.php
adminer/schema.inc.php
adminer/script.inc.php

index 4118f3752bff9f013035141f1b703f487a80dc4a..02fa52ee9efcbf56fe1b7ccbac021b0908ff637b 100644 (file)
@@ -66,28 +66,28 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
                        
                        if ($_POST["table_style"] || $_POST["data_style"]) {
                                $views = array();
-                               foreach (table_status() as $table_status) {
-                                       $table = (DB == "" || in_array($table_status["Name"], (array) $_POST["tables"]));
-                                       $data = (DB == "" || in_array($table_status["Name"], (array) $_POST["data"]));
+                               foreach (table_status() as $name => $table_status) {
+                                       $table = (DB == "" || in_array($name, (array) $_POST["tables"]));
+                                       $data = (DB == "" || in_array($name, (array) $_POST["data"]));
                                        if ($table || $data) {
                                                if (!is_view($table_status)) {
                                                        if ($ext == "tar") {
                                                                ob_start();
                                                        }
-                                                       $adminer->dumpTable($table_status["Name"], ($table ? $_POST["table_style"] : ""));
+                                                       $adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""));
                                                        if ($data) {
-                                                               $adminer->dumpData($table_status["Name"], $_POST["data_style"], "SELECT * FROM " . table($table_status["Name"]));
+                                                               $adminer->dumpData($name, $_POST["data_style"], "SELECT * FROM " . table($name));
                                                        }
-                                                       if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($table_status["Name"], $_POST["table_style"]))) {
+                                                       if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
                                                                echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
                                                        }
                                                        if ($ext == "tar") {
-                                                               echo tar_file((DB != "" ? "" : "$db/") . "$table_status[Name].csv", ob_get_clean());
+                                                               echo tar_file((DB != "" ? "" : "$db/") . "$name.csv", ob_get_clean());
                                                        } elseif ($is_sql) {
                                                                echo "\n";
                                                        }
                                                } elseif ($is_sql) {
-                                                       $views[] = $table_status["Name"];
+                                                       $views[] = $name;
                                                }
                                        }
                                }
@@ -153,8 +153,7 @@ if (DB != "") {
        echo "</thead>\n";
        $views = "";
        //! defer number of rows to JavaScript
-       foreach (table_status() as $table_status) {
-               $name = $table_status["Name"];
+       foreach (table_status() as $name => $table_status) {
                $prefix = ereg_replace("_.*", "", $name);
                $checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
                $print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "checkboxClick(event, this); formUncheck('check-tables');");
index a60d4529a0bd73dbace06fd6cafac46fc0e7abaa..fd1171f08f51942421227ac11c55edc4ba793ba6 100644 (file)
@@ -16,23 +16,23 @@ $base_left = -1;
 $schema = array(); // table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
 $referenced = array(); // target_table => array(table => array(left => target_column))
 $lefts = array(); // float => bool
-foreach (table_status() as $table_status) {
+foreach (table_status() as $table => $table_status) {
        if (!isset($table_status["Engine"])) { // view
                continue;
        }
        $pos = 0;
-       $schema[$table_status["Name"]]["fields"] = array();
-       foreach (fields($table_status["Name"]) as $name => $field) {
+       $schema[$table]["fields"] = array();
+       foreach (fields($table) as $name => $field) {
                $pos += 1.25;
                $field["pos"] = $pos;
-               $schema[$table_status["Name"]]["fields"][$name] = $field;
+               $schema[$table]["fields"][$name] = $field;
        }
-       $schema[$table_status["Name"]]["pos"] = ($table_pos[$table_status["Name"]] ? $table_pos[$table_status["Name"]] : array($top, 0));
-       foreach ($adminer->foreignKeys($table_status["Name"]) as $val) {
+       $schema[$table]["pos"] = ($table_pos[$table] ? $table_pos[$table] : array($top, 0));
+       foreach ($adminer->foreignKeys($table) as $val) {
                if (!$val["db"]) {
                        $left = $base_left;
-                       if ($table_pos[$table_status["Name"]][1] || $table_pos[$val["table"]][1]) {
-                               $left = min(floatval($table_pos[$table_status["Name"]][1]), floatval($table_pos[$val["table"]][1])) - 1;
+                       if ($table_pos[$table][1] || $table_pos[$val["table"]][1]) {
+                               $left = min(floatval($table_pos[$table][1]), floatval($table_pos[$val["table"]][1])) - 1;
                        } else {
                                $base_left -= .1;
                        }
@@ -40,12 +40,12 @@ foreach (table_status() as $table_status) {
                                // find free $left
                                $left -= .0001;
                        }
-                       $schema[$table_status["Name"]]["references"][$val["table"]][(string) $left] = array($val["source"], $val["target"]);
-                       $referenced[$val["table"]][$table_status["Name"]][(string) $left] = $val["target"];
+                       $schema[$table]["references"][$val["table"]][(string) $left] = array($val["source"], $val["target"]);
+                       $referenced[$val["table"]][$table][(string) $left] = $val["target"];
                        $lefts[(string) $left] = true;
                }
        }
-       $top = max($top, $schema[$table_status["Name"]]["pos"][0] + 2.5 + $pos);
+       $top = max($top, $schema[$table]["pos"][0] + 2.5 + $pos);
 }
 
 ?>
index c5ee1fbd1ca6bcef7270d0dea95d221bf29113a3..099c47bb7ee6f438f771eee1a9c9225f9a60011e 100644 (file)
@@ -3,8 +3,8 @@ header("Content-Type: text/javascript; charset=utf-8");
 
 if ($_GET["script"] == "db") {
        $sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
-       foreach (table_status() as $table_status) {
-               $id = js_escape($table_status["Name"]);
+       foreach (table_status() as $name => $table_status) {
+               $id = js_escape($name);
                json_row("Comment-$id", nbsp($table_status["Comment"]));
                if (!is_view($table_status)) {
                        foreach (array("Engine", "Collation") as $key) {