diff --git a/adminer/createv.inc.php b/adminer/createv.inc.php deleted file mode 100644 index 2e5a1ef4..00000000 --- a/adminer/createv.inc.php +++ /dev/null @@ -1,31 +0,0 @@ - $_GET["createv"]), $_GET["createv"]); - -$row = array(); -if ($_POST) { - $row = $_POST; -} elseif (strlen($_GET["createv"])) { - $row = view($_GET["createv"]); - $row["name"] = $_GET["createv"]; -} -?> - -
diff --git a/adminer/db.inc.php b/adminer/db.inc.php index abe08d81..ba068171 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -54,15 +54,16 @@ if (!$table_status) { $name = $row["Name"]; table_comment($row); echo '' . lang('Create view') . "\n"; + echo '
' . lang('Create view') . "\n"; echo "
\n";
- foreach ($table_status as $row) {
- echo '' . lang('select') . ' ';
- echo '' . adminer_table_name($row) . "
\n";
+ while ($row = $result->fetch_row()) {
+ echo '' . lang('select') . ' ';
+ echo '' . adminer_table_name(array("Name" => $row[0])) . "
\n"; //! Adminer::table_name may work with full table status
}
}
+ $result->free();
echo '
' . lang('Create new table') . "\n"; } } diff --git a/adminer/index.php b/adminer/index.php index f2c2bc2d..3e445478 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -15,8 +15,6 @@ if (isset($_GET["download"])) { include "./download.inc.php"; } elseif (isset($_GET["table"])) { include "./table.inc.php"; -} elseif (isset($_GET["view"])) { - include "./view.inc.php"; } elseif (isset($_GET["schema"])) { include "./schema.inc.php"; } elseif (isset($_GET["dump"])) { @@ -51,8 +49,8 @@ if (isset($_GET["download"])) { include "./call.inc.php"; } elseif (isset($_GET["foreign"])) { include "./foreign.inc.php"; - } elseif (isset($_GET["createv"])) { - include "./createv.inc.php"; + } elseif (isset($_GET["view"])) { + include "./view.inc.php"; } elseif (isset($_GET["event"])) { include "./event.inc.php"; } elseif (isset($_GET["procedure"])) { diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 5751e465..0f73572a 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -3,11 +3,12 @@ $result = $dbh->query("SHOW COLUMNS FROM " . idf_escape($_GET["table"])); if (!$result) { $error = htmlspecialchars($dbh->error); } +$table_status = ($result ? table_status($_GET["table"]) : array()); +$is_view = !isset($table_status["Rows"]); -page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"]), $error); +page_header(($result && $is_view ? lang('View') : lang('Table')) . ": " . htmlspecialchars($_GET["table"]), $error); if ($result) { - $table_status = table_status($_GET["table"]); $auto_increment_only = true; echo "
$index[type] | " . implode(", ", $print) . "\n"; - } - echo " |
---|
' . lang('Alter indexes') . "\n"; - - if ($table_status["Engine"] == "InnoDB") { - echo "
" . implode(", ", array_map('htmlspecialchars', $foreign_key["source"])) . ""; - echo ' | $link"; - echo "(" . implode(", ", array_map('htmlspecialchars', $foreign_key["target"])) . ")"; - echo " | " . (!strlen($foreign_key["db"]) ? '' . lang('Alter') . '' : ' '); + foreach ($indexes as $index) { + ksort($index["columns"]); // enforce correct columns order + $print = array(); + foreach ($index["columns"] as $key => $val) { + $print[] = "" . htmlspecialchars($val) . "" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : ""); + } + echo " |
---|---|---|
$index[type] | " . implode(", ", $print) . "\n"; } echo " |
' . lang('Add foreign key') . "\n"; - } -} - -if ($dbh->server_info >= 5) { - echo "
$row[Timing] | $row[Event] | " . htmlspecialchars($row["Trigger"]) . " | ' . lang('Alter') . "\n";
+ echo ' ' . lang('Alter indexes') . "\n"; + + if ($table_status["Engine"] == "InnoDB") { + echo " " . lang('Foreign keys') . "\n"; + $foreign_keys = foreign_keys($_GET["table"]); + if ($foreign_keys) { + echo "
' . lang('Add foreign key') . "\n"; + } + + if ($dbh->server_info >= 5) { + echo " " . lang('Triggers') . "\n"; + $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($_GET["table"], "%_"))); + if ($result->num_rows) { + echo "
' . lang('Add trigger') . "\n"; } - echo " |
---|
' . lang('Add trigger') . "\n"; } diff --git a/adminer/view.inc.php b/adminer/view.inc.php index 7540dae5..1b7a77e7 100644 --- a/adminer/view.inc.php +++ b/adminer/view.inc.php @@ -1,6 +1,31 @@ " . htmlspecialchars($view["select"]) . "\n"; -echo '
' . lang('Alter view') . "\n"; +page_header((strlen($_GET["view"]) ? lang('Alter view') : lang('Create view')), $error, array("table" => $_GET["view"]), $_GET["view"]); + +$row = array(); +if ($_POST) { + $row = $_POST; +} elseif (strlen($_GET["view"])) { + $row = view($_GET["view"]); + $row["name"] = $_GET["view"]; +} +?> + +
diff --git a/changes.txt b/changes.txt index a3aa5897..2679f4cc 100644 --- a/changes.txt +++ b/changes.txt @@ -10,6 +10,7 @@ Preselect now() for timestamp columns (thanks to paranoiq) Clear history (thanks to paranoiq) Remove Delete button from Edit page - use mass operation for it Faster multiple update, clone and delete +Faster table list in navigation Use HTML Strict instead of XHTML Fix grant ALL PRIVILEGES with GRANT OPTION Fix CSV import diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index b9ae9c3d..acce9c70 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -27,9 +27,9 @@ function adminer_login($login, $password) { return call_adminer('login', true, $login, $password); } -function adminer_table_name($row) { - table_comment($row); - return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row); +function adminer_table_name($table_status) { + table_comment($table_status); + return call_adminer('table_name', htmlspecialchars(strlen($table_status["Comment"]) ? $table_status["Comment"] : $table_status["Name"]), $table_status); } function adminer_field_name($field) { @@ -48,7 +48,7 @@ FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . " AND REFERENCED_TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . " AND REFERENCED_TABLE_NAME = " . $dbh->quote($table) . " -ORDER BY ORDINAL_POSITION"); +ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 if ($result) { while ($row = $result->fetch_assoc()) { $return[$row["TABLE_NAME"]][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];