1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) { queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once } if ($_POST["truncate"]) { if ($_POST["tables"]) { $result = truncate_tables($_POST["tables"]); } $message = lang('Tables have been truncated.'); } elseif ($_POST["move"]) { $result = move_tables((array) $_POST["tables"], (array) $_POST["views"], $_POST["target"]); $message = lang('Tables have been moved.'); } elseif ($_POST["copy"]) { $result = copy_tables((array) $_POST["tables"], (array) $_POST["views"], $_POST["target"]); $message = lang('Tables have been copied.'); } elseif ($_POST["drop"]) { if ($_POST["views"]) { $result = drop_views($_POST["views"]); } if ($result && $_POST["tables"]) { $result = drop_tables($_POST["tables"]); } $message = lang('Tables have been dropped.'); } elseif ($jush != "sql") { $result = ($jush == "sqlite" ? queries("VACUUM") : apply_queries("VACUUM" . ($_POST["optimize"] ? "" : " ANALYZE"), $_POST["tables"]) ); $message = lang('Tables have been optimized.'); } elseif (!$_POST["tables"]) { $message = lang('No tables.'); } elseif ($result = queries(($_POST["optimize"] ? "OPTIMIZE" : ($_POST["check"] ? "CHECK" : ($_POST["repair"] ? "REPAIR" : "ANALYZE"))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) { while ($row = $result->fetch_assoc()) { $message .= "" . h($row["Table"]) . ": " . h($row["Msg_text"]) . "
"; } } queries_redirect(substr(ME, 0, -1), $message, $result); } page_header(($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"])), $error, true); if ($adminer->homepage()) { if ($_GET["ns"] !== "") { echo "

" . lang('Tables and views') . "

\n"; $tables_list = tables_list(); if (!$tables_list) { echo "

" . lang('No tables.') . "\n"; } else { echo "

\n"; if (support("table")) { echo "
" . lang('Search data in tables') . "
"; echo ""; echo script("qsl('input').onkeydown = partialArg(bodyKeydown, 'search');", ""); echo " \n"; if ($adminer->operator_regexp !== null) { echo "

'; echo doc_link(array('sql' => 'regexp.html', 'pgsql' => 'functions-matching.html#FUNCTIONS-POSIX-REGEXP')) . "

\n"; } echo "
\n"; if ($_POST["search"] && $_POST["query"] != "") { $_GET["where"][0]["op"] = $adminer->operator_regexp === null || empty($_POST['regexp']) ? "LIKE %%" : $adminer->operator_regexp; search_tables(); } } echo "
\n"; echo "\n"; echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});"); echo ''; echo '\n"; $tables = 0; foreach ($tables_list as $name => $type) { $view = ($type !== null && !preg_match('~table|sequence~i', $type)); $id = h("Table-" . $name); echo '
' . script("qs('#check-all').onclick = partial(formCheck, /^(tables|views)\[/);", ""); echo '' . lang('Table'); echo '' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html')); echo '' . lang('Collation') . doc_link(array('sql' => 'charset-charsets.html', 'mariadb' => 'supported-character-sets-and-collations/')); echo '' . lang('Data Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT', 'oracle' => 'REFRN20286')); echo '' . lang('Index Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT')); echo '' . lang('Data Free') . doc_link(array('sql' => 'show-table-status.html')); echo '' . lang('Auto Increment') . doc_link(array('sql' => 'example-auto-increment.html', 'mariadb' => 'auto_increment/')); echo '' . lang('Rows') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'catalog-pg-class.html#CATALOG-PG-CLASS', 'oracle' => 'REFRN20286')); echo (support("comment") ? '' . lang('Comment') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-info.html#FUNCTIONS-INFO-COMMENT-TABLE')) : ''); echo "
' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "", "", $id); echo '' . (support("table") || support("indexes") ? "" . h($name) . '' : h($name)); if ($view) { echo '' . (preg_match('~materialized~i', $type) ? lang('Materialized view') : lang('View')) . ''; echo '?'; } else { foreach (array( "Engine" => array(), "Collation" => array(), "Data_length" => array("create", lang('Alter table')), "Index_length" => array("indexes", lang('Alter indexes')), "Data_free" => array("edit", lang('New item')), "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), "Rows" => array("select", lang('Select data')), ) as $key => $link) { $id = " id='$key-" . h($name) . "'"; echo ($link ? "" . (support("table") || $key == "Rows" || (support("indexes") && $key != "Data_length") ? "?" : "?" ) : ""); } $tables++; } echo (support("comment") ? "" : ""); } echo "
" . lang('%d in total', count($tables_list)); echo "" . h($jush == "sql" ? $connection->result("SELECT @@default_storage_engine") : ""); echo "" . h(db_collation(DB, collations())); foreach (array("Data_length", "Index_length", "Data_free") as $key) { echo ""; } echo "
\n"; echo "
\n"; if (!information_schema(DB)) { echo "\n"; } echo "
\n"; echo script("tableCheck();"); } $links = []; $links[] = "" . lang('Create table') . ""; if (support("view")) { $links[] = "" . lang('Create view') . ""; } echo generate_linksbar($links); if (support("routine")) { echo "

" . lang('Routines') . "

\n"; $routines = routines(); if ($routines) { echo "\n"; echo '\n"; odd(''); foreach ($routines as $row) { $name = ($row["SPECIFIC_NAME"] == $row["ROUTINE_NAME"] ? "" : "&name=" . urlencode($row["ROUTINE_NAME"])); // not computed on the pages to be able to print the header first echo ''; echo '
' . lang('Name') . '' . lang('Type') . '' . lang('Return type') . "
' . h($row["ROUTINE_NAME"]) . ''; echo '' . h($row["ROUTINE_TYPE"]); echo '' . h($row["DTD_IDENTIFIER"]); echo '' . lang('Alter') . ""; } echo "
\n"; } $links = []; if (support('procedure')) { $links[] = "" . lang('Create procedure') . ""; } $links[] = "" . lang('Create function') . ""; echo generate_linksbar($links); } if (support("sequence")) { echo "

" . lang('Sequences') . "

\n"; $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema() ORDER BY sequence_name"); if ($sequences) { echo "\n"; echo "\n"; odd(''); foreach ($sequences as $val) { echo "
" . lang('Name') . "
" . h($val) . "\n"; } echo "
\n"; } echo generate_linksbar(["" . lang('Create sequence') . ""]); } if (support("type")) { echo "

" . lang('User types') . "

\n"; $user_types = types(); if ($user_types) { echo "\n"; echo "\n"; odd(''); foreach ($user_types as $val) { echo "
" . lang('Name') . "
" . h($val) . "\n"; } echo "
\n"; } echo generate_linksbar(["" . lang('Create type') . ""]); } if (support("event")) { echo "

" . lang('Events') . "

\n"; $rows = get_rows("SHOW EVENTS"); if ($rows) { echo "\n"; echo "\n"; foreach ($rows as $row) { echo ""; echo "
" . lang('Name') . "" . lang('Schedule') . "" . lang('Start') . "" . lang('End') . "
" . h($row["Name"]); echo "" . ($row["Execute at"] ? lang('At given time') . "" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "$row[Starts]"); echo "$row[Ends]"; echo '' . lang('Alter') . ''; } echo "
\n"; $event_scheduler = $connection->result("SELECT @@event_scheduler"); if ($event_scheduler && $event_scheduler != "ON") { echo "

event_scheduler: " . h($event_scheduler) . "\n"; } } echo generate_linksbar(["" . lang('Create event') . ""]); } if ($tables_list) { echo script("ajaxSetHtml('" . js_escape(ME) . "script=db');"); } } }