Separate table_status
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@774 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
a02d61c131
commit
caeb30f501
|
@ -43,14 +43,14 @@ echo '<p><a href="' . htmlspecialchars($SELF) . 'database=">' . lang('Alter data
|
||||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'schema=">' . lang('Database schema') . "</a></p>\n";
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'schema=">' . lang('Database schema') . "</a></p>\n";
|
||||||
|
|
||||||
echo "<h3>" . lang('Tables and views') . "</h3>\n";
|
echo "<h3>" . lang('Tables and views') . "</h3>\n";
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
$table_status = table_status();
|
||||||
if (!$result->num_rows) {
|
if (!$table_status) {
|
||||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||||
} 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|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";
|
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()) {
|
foreach ($table_status as $row) {
|
||||||
$name = $row["Name"];
|
$name = $row["Name"];
|
||||||
table_comment($row);
|
table_comment($row);
|
||||||
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>';
|
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>';
|
||||||
|
@ -75,7 +75,6 @@ if (!$result->num_rows) {
|
||||||
}
|
}
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
$result->free();
|
|
||||||
|
|
||||||
if ($dbh->server_info >= 5) {
|
if ($dbh->server_info >= 5) {
|
||||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=">' . lang('Create view') . "</a></p>\n";
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=">' . lang('Create view') . "</a></p>\n";
|
||||||
|
|
|
@ -71,8 +71,7 @@ if ($_POST) {
|
||||||
|
|
||||||
if ($_POST["table_style"] || $_POST["data_style"]) {
|
if ($_POST["table_style"] || $_POST["data_style"]) {
|
||||||
$views = array();
|
$views = array();
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
foreach (table_status() as $row) {
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$table = (!strlen($_GET["db"]) || in_array($row["Name"], (array) $_POST["tables"]));
|
$table = (!strlen($_GET["db"]) || in_array($row["Name"], (array) $_POST["tables"]));
|
||||||
$data = (!strlen($_GET["db"]) || in_array($row["Name"], (array) $_POST["data"]));
|
$data = (!strlen($_GET["db"]) || in_array($row["Name"], (array) $_POST["data"]));
|
||||||
if ($table || $data) {
|
if ($table || $data) {
|
||||||
|
@ -97,7 +96,6 @@ if ($_POST) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result->free();
|
|
||||||
foreach ($views as $view) {
|
foreach ($views as $view) {
|
||||||
dump_table($view, $_POST["table_style"], true);
|
dump_table($view, $_POST["table_style"], true);
|
||||||
}
|
}
|
||||||
|
@ -182,8 +180,7 @@ if (strlen($_GET["db"])) {
|
||||||
echo "<th align='right'><label>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='form_check(this, /^data\\[/);' /></label></th>";
|
echo "<th align='right'><label>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='form_check(this, /^data\\[/);' /></label></th>";
|
||||||
echo "</tr></thead>\n";
|
echo "</tr></thead>\n";
|
||||||
$views = "";
|
$views = "";
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
foreach (table_status() as $row) {
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$checked = (strlen($_GET["dump"]) && $row["Name"] != $_GET["dump"] ? '' : " checked='checked'");
|
$checked = (strlen($_GET["dump"]) && $row["Name"] != $_GET["dump"] ? '' : " checked='checked'");
|
||||||
$print = '<tr><td><label><input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . "\"$checked onclick=\"form_uncheck('check-tables');\" />" . htmlspecialchars($row["Name"]) . "</label></td>";
|
$print = '<tr><td><label><input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . "\"$checked onclick=\"form_uncheck('check-tables');\" />" . htmlspecialchars($row["Name"]) . "</label></td>";
|
||||||
if (!$row["Engine"]) {
|
if (!$row["Engine"]) {
|
||||||
|
|
|
@ -20,15 +20,6 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
|
||||||
}
|
}
|
||||||
page_header(lang('Foreign key'), $error, array("table" => $_GET["foreign"]), $_GET["foreign"]);
|
page_header(lang('Foreign key'), $error, array("table" => $_GET["foreign"]), $_GET["foreign"]);
|
||||||
|
|
||||||
$tables = array();
|
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
if ($row["Engine"] == "InnoDB") {
|
|
||||||
$tables[] = $row["Name"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$result->free();
|
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$row = $_POST;
|
$row = $_POST;
|
||||||
ksort($row["source"]);
|
ksort($row["source"]);
|
||||||
|
@ -52,7 +43,7 @@ $target = ($_GET["foreign"] === $row["table"] ? $source : get_vals("SHOW COLUMNS
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<p>
|
<p>
|
||||||
<?php echo lang('Target table'); ?>:
|
<?php echo lang('Target table'); ?>:
|
||||||
<select name="table" onchange="this.form['change-js'].value = '1'; this.form.submit();"><?php echo optionlist($tables, $row["table"]); ?></select>
|
<select name="table" onchange="this.form['change-js'].value = '1'; this.form.submit();"><?php echo optionlist(array_keys(table_status_referencable()), $row["table"]); ?></select>
|
||||||
<input type="hidden" name="change-js" value="" />
|
<input type="hidden" name="change-js" value="" />
|
||||||
</p>
|
</p>
|
||||||
<noscript><p><input type="submit" name="change" value="<?php echo lang('Change'); ?>" /></p></noscript>
|
<noscript><p><input type="submit" name="change" value="<?php echo lang('Change'); ?>" /></p></noscript>
|
||||||
|
|
|
@ -89,19 +89,18 @@ function page_footer($missing = false) {
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
if ($missing != "db" && strlen($_GET["db"])) {
|
if ($missing != "db" && strlen($_GET["db"])) {
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
$table_status = table_status();
|
||||||
if (!$result->num_rows) {
|
if (!$table_status) {
|
||||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<p>\n";
|
echo "<p>\n";
|
||||||
while ($row = $result->fetch_assoc()) {
|
foreach ($table_status as $row) {
|
||||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
|
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
|
||||||
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a><br />\n";
|
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a><br />\n";
|
||||||
}
|
}
|
||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
}
|
}
|
||||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a></p>\n";
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a></p>\n";
|
||||||
$result->free();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -223,11 +223,24 @@ function get_databases() {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_status($table) {
|
function table_status($name = "") {
|
||||||
global $dbh;
|
global $dbh;
|
||||||
$result = $dbh->query("SHOW TABLE STATUS LIKE " . $dbh->quote(addcslashes($table, "%_")));
|
$return = array();
|
||||||
$return = $result->fetch_assoc(); // ()-> is not supported in PHP 4
|
$result = $dbh->query("SHOW TABLE STATUS" . (strlen($name) ? " LIKE " . $dbh->quote(addcslashes($name, "%_")) : ""));
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$return[$row["Name"]] = $row;
|
||||||
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
|
return (strlen($name) ? $return[$name] : $return);
|
||||||
|
}
|
||||||
|
|
||||||
|
function table_status_referencable() {
|
||||||
|
$return = array();
|
||||||
|
foreach (table_status() as $name => $row) {
|
||||||
|
if ($row["Engine"] == "InnoDB") {
|
||||||
|
$return[$name] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,7 @@ $base_left = -1;
|
||||||
$schema = array(); // table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
|
$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))
|
$referenced = array(); // target_table => array(table => array(left => target_column))
|
||||||
$lefts = array(); // float => bool
|
$lefts = array(); // float => bool
|
||||||
$result = $dbh->query("SHOW TABLE STATUS");
|
foreach (table_status() as $row) {
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
if (!isset($row["Engine"])) { // view
|
if (!isset($row["Engine"])) { // view
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +48,6 @@ while ($row = $result->fetch_assoc()) {
|
||||||
}
|
}
|
||||||
$top = max($top, $schema[$row["Name"]]["pos"][0] + 2.5 + $pos);
|
$top = max($top, $schema[$row["Name"]]["pos"][0] + 2.5 + $pos);
|
||||||
}
|
}
|
||||||
$result->free();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div id="schema" style="height: <?php echo $top; ?>em;">
|
<div id="schema" style="height: <?php echo $top; ?>em;">
|
||||||
|
|
Loading…
Reference in a new issue