Move and drop views
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@671 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
97123b6739
commit
328c7a74cf
23
db.inc.php
23
db.inc.php
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
if ($_POST["tables"] && !$error) {
|
$tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]);
|
||||||
|
|
||||||
|
if ($tables_views && !$error) {
|
||||||
$result = true;
|
$result = true;
|
||||||
$message = "";
|
$message = "";
|
||||||
if (isset($_POST["truncate"])) {
|
if (isset($_POST["truncate"])) {
|
||||||
|
if ($_POST["tables"]) {
|
||||||
foreach ($_POST["tables"] as $table) {
|
foreach ($_POST["tables"] as $table) {
|
||||||
if (!queries("TRUNCATE " . idf_escape($table))) {
|
if (!queries("TRUNCATE " . idf_escape($table))) {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
@ -10,14 +13,17 @@ if ($_POST["tables"] && !$error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$message = lang('Tables have been truncated.');
|
$message = lang('Tables have been truncated.');
|
||||||
|
}
|
||||||
} elseif (isset($_POST["move"])) {
|
} elseif (isset($_POST["move"])) {
|
||||||
$rename = array();
|
$rename = array();
|
||||||
foreach ($_POST["tables"] as $table) {
|
foreach ($tables_views as $table) {
|
||||||
$rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table);
|
$rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table);
|
||||||
}
|
}
|
||||||
$result = queries("RENAME TABLE " . implode(", ", $rename));
|
$result = queries("RENAME TABLE " . implode(", ", $rename));
|
||||||
$message = lang('Tables have been moved.');
|
$message = lang('Tables have been moved.');
|
||||||
} elseif ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) {
|
} elseif ((!isset($_POST["drop"]) || !$_POST["views"] || queries("DROP VIEW " . implode(", ", array_map('idf_escape', $_POST["views"]))))
|
||||||
|
&& (!$_POST["tables"] || ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))))
|
||||||
|
) {
|
||||||
if (isset($_POST["drop"])) {
|
if (isset($_POST["drop"])) {
|
||||||
$message = lang('Tables have been dropped.');
|
$message = lang('Tables have been dropped.');
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,19 +46,20 @@ if (!$result->num_rows) {
|
||||||
} else {
|
} else {
|
||||||
echo "<form action='' method='post'>\n";
|
echo "<form action='' method='post'>\n";
|
||||||
echo "<table cellspacing='0' class='nowrap'>\n";
|
echo "<table cellspacing='0' class='nowrap'>\n";
|
||||||
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="form_check(this, /^tables\[/);" /></td><th>' . lang('Table') . '</th><td>' . lang('Engine') . '</td><td>' . lang('Collation') . '</td><td>' . lang('Data Length') . '</td><td>' . lang('Index Length') . '</td><td>' . lang('Data Free') . '</td><td>' . lang('Auto Increment') . '</td><td>' . lang('Rows') . '</td><td>' . lang('Comment') . "</td></tr></thead>\n";
|
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="form_check(this, /^(tables|views)\[/);" /></td><th>' . lang('Table') . '</th><td>' . lang('Engine') . '</td><td>' . lang('Collation') . '</td><td>' . lang('Data Length') . '</td><td>' . lang('Index Length') . '</td><td>' . lang('Data Free') . '</td><td>' . lang('Auto Increment') . '</td><td>' . lang('Rows') . '</td><td>' . lang('Comment') . "</td></tr></thead>\n";
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$name = $row["Name"];
|
||||||
table_comment($row);
|
table_comment($row);
|
||||||
echo '<tr' . odd() . '><td><input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '"' . (in_array($row["Name"], (array) $_POST["tables"], true) ? ' checked="checked"' : '') . ' onclick="form_uncheck(\'check-all\');" /></td>';
|
echo '<tr' . odd() . '><td><input type="checkbox" name="' . (isset($row["Rows"]) ? 'tables' : 'views') . '[]" value="' . htmlspecialchars($name) . '"' . (in_array($name, $tables_views, true) ? ' checked="checked"' : '') . ' onclick="form_uncheck(\'check-all\');" /></td>';
|
||||||
if (isset($row["Rows"])) {
|
if (isset($row["Rows"])) {
|
||||||
echo '<th><a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th><td>$row[Engine]</td><td>$row[Collation]</td>";
|
echo '<th><a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($name) . '">' . htmlspecialchars($name) . "</a></th><td>$row[Engine]</td><td>$row[Collation]</td>";
|
||||||
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) {
|
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) {
|
||||||
$val = number_format($row[$key], 0, '.', lang(','));
|
$val = number_format($row[$key], 0, '.', lang(','));
|
||||||
echo '<td align="right">' . (strlen($row[$key]) ? '<a href="' . htmlspecialchars("$SELF$link=") . urlencode($row["Name"]) . '">' . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val) . '</a>' : ' ') . '</td>';
|
echo '<td align="right">' . (strlen($row[$key]) ? '<a href="' . htmlspecialchars("$SELF$link=") . urlencode($name) . '">' . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val) . '</a>' : ' ') . '</td>';
|
||||||
}
|
}
|
||||||
echo "<td>" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "</td>";
|
echo "<td>" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "</td>";
|
||||||
} else {
|
} else {
|
||||||
echo '<th><a href="' . htmlspecialchars($SELF) . 'view=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . '</a></th><td colspan="8"><a href="' . htmlspecialchars($SELF) . "select=" . urlencode($row["Name"]) . '">' . lang('View') . '</a></td>';
|
echo '<th><a href="' . htmlspecialchars($SELF) . 'view=' . urlencode($name) . '">' . htmlspecialchars($name) . '</a></th><td colspan="8"><a href="' . htmlspecialchars($SELF) . "select=" . urlencode($name) . '">' . lang('View') . '</a></td>';
|
||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue