git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@65 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-06 13:03:13 +00:00
parent 4e620135ed
commit ffcea8b587
4 changed files with 190 additions and 157 deletions

View file

@ -16,18 +16,28 @@ function dump($db) {
} }
} }
echo "CREATE DATABASE IF NOT EXISTS " . idf_escape($db) . ";\n"; $result = mysql_query("SHOW CREATE DATABASE " . idf_escape($db));
if ($result) {
echo mysql_result($result, 0) . ";\n";
mysql_free_result($result);
}
echo "USE " . idf_escape($db) . ";\n"; echo "USE " . idf_escape($db) . ";\n";
echo "SET CHARACTER SET utf8;\n\n"; echo "SET CHARACTER SET utf8;\n\n";
$result = mysql_query("SHOW TABLES"); $result = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_row($result)) { while ($row = mysql_fetch_row($result)) {
echo mysql_result(mysql_query("SHOW CREATE TABLE " . idf_escape($row[0])), 0, 1) . ";\n"; $result1 = mysql_query("SHOW CREATE TABLE " . idf_escape($row[0]));
$result1 = mysql_query("SELECT * FROM " . idf_escape($row[0])); //! except views //! enum and set as numbers if ($result1) {
while ($row1 = mysql_fetch_row($result1)) { echo mysql_result($result1, 0, 1) . ";\n";
echo "INSERT INTO " . idf_escape($row[0]) . " VALUES ('" . implode("', '", array_map('mysql_real_escape_string', $row1)) . "');\n"; mysql_free_result($result1);
$result1 = mysql_query("SELECT * FROM " . idf_escape($row[0])); //! except views //! enum and set as numbers
if ($result1) {
while ($row1 = mysql_fetch_row($result1)) {
echo "INSERT INTO " . idf_escape($row[0]) . " VALUES ('" . implode("', '", array_map('mysql_real_escape_string', $row1)) . "');\n";
}
mysql_free_result($result1);
}
echo "\n";
} }
mysql_free_result($result1);
echo "\n";
} }
mysql_free_result($result); mysql_free_result($result);
@ -36,6 +46,7 @@ function dump($db) {
echo "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW $row[Statement];\n\n"; //! delimiter echo "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW $row[Statement];\n\n"; //! delimiter
} }
mysql_free_result($result); mysql_free_result($result);
echo "\n\n";
echo implode("", (array) $routines[$db]); echo implode("", (array) $routines[$db]);
} }

View file

@ -32,20 +32,23 @@ function optionlist($options, $selected = array(), $not_vals = false) {
function fields($table) { function fields($table) {
$return = array(); $return = array();
$result = mysql_query("SHOW FULL COLUMNS FROM " . idf_escape($table)); $result = mysql_query("SHOW FULL COLUMNS FROM " . idf_escape($table));
while ($row = mysql_fetch_assoc($result)) { if ($result) {
preg_match('~^([^(]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match); while ($row = mysql_fetch_assoc($result)) {
$return[$row["Field"]] = array( preg_match('~^([^(]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
"field" => $row["Field"], $return[$row["Field"]] = array(
"type" => $match[1], "field" => $row["Field"],
"length" => $match[2], "type" => $match[1],
"unsigned" => ltrim($match[3] . $match[4]), "length" => $match[2],
"default" => $row["Default"], "unsigned" => ltrim($match[3] . $match[4]),
"null" => ($row["Null"] != "NO"), "default" => $row["Default"],
"extra" => $row["Extra"], "null" => ($row["Null"] != "NO"),
"collation" => $row["Collation"], "extra" => $row["Extra"],
); "collation" => $row["Collation"],
"privileges" => explode(",", $row["Privileges"]),
);
}
mysql_free_result($result);
} }
mysql_free_result($result);
return $return; return $return;
} }
@ -63,12 +66,16 @@ function indexes($table) {
function foreign_keys($table) { function foreign_keys($table) {
static $pattern = '~`((?:[^`]*|``)+)`~'; static $pattern = '~`((?:[^`]*|``)+)`~';
$return = array(); $return = array();
$create_table = mysql_result(mysql_query("SHOW CREATE TABLE " . idf_escape($table)), 0, 1); $result = mysql_query("SHOW CREATE TABLE " . idf_escape($table));
preg_match_all('~FOREIGN KEY \\((.+)\\) REFERENCES (?:`(.+)`\\.)?`(.+)` \\((.+)\\)~', $create_table, $matches, PREG_SET_ORDER); if ($result) {
foreach ($matches as $match) { $create_table = mysql_result($result, 0, 1);
preg_match_all($pattern, $match[1], $source); mysql_free_result($result);
preg_match_all($pattern, $match[4], $target); preg_match_all('~FOREIGN KEY \\((.+)\\) REFERENCES (?:`(.+)`\\.)?`(.+)` \\((.+)\\)~', $create_table, $matches, PREG_SET_ORDER);
$return[] = array(idf_unescape($match[2]), idf_unescape($match[3]), array_map('idf_unescape', $source[1]), array_map('idf_unescape', $target[1])); foreach ($matches as $match) {
preg_match_all($pattern, $match[1], $source);
preg_match_all($pattern, $match[4], $target);
$return[] = array(idf_unescape($match[2]), idf_unescape($match[3]), array_map('idf_unescape', $source[1]), array_map('idf_unescape', $target[1]));
}
} }
return $return; return $return;
} }

View file

@ -1,30 +1,39 @@
<?php <?php
$indexes = indexes($_GET["select"]);
page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"])); page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]));
echo '<p><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '">' . lang('New item') . "</a></p>\n"; echo '<p><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '">' . lang('New item') . "</a></p>\n";
echo "<form action='' id='form'>\n<fieldset><legend>" . lang('Search') . "</legend>\n"; $fields = fields($_GET["select"]);
if (strlen($_GET["server"])) { $columns = array();
echo '<input type="hidden" name="server" value="' . htmlspecialchars($_GET["server"]) . '" />'; foreach ($fields as $key => $field) {
} if (in_array("select", $field["privileges"])) {
echo '<input type="hidden" name="db" value="' . htmlspecialchars($_GET["db"]) . '" />'; $columns[] = $key;
echo '<input type="hidden" name="select" value="' . htmlspecialchars($_GET["select"]) . '" />';
echo "\n";
$where = array();
$columns = array_keys(fields($_GET["select"]));
$operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IS NULL");
$i = 0;
foreach ((array) $_GET["where"] as $val) {
if ($val["col"] && in_array($val["op"], $operators)) {
$where[] = idf_escape($val["col"]) . " $val[op]" . ($val["op"] != "IS NULL" ? " '" . mysql_real_escape_string($val["val"]) . "'" : "");
echo "<div><select name='where[$i][col]'><option></option>" . optionlist($columns, $val["col"], "not_vals") . "</select>";
echo "<select name='where[$i][op]' onchange=\"where_change(this);\">" . optionlist($operators, $val["op"], "not_vals") . "</select>";
echo "<input name='where[$i][val]' value=\"" . htmlspecialchars($val["val"]) . "\" /></div>\n";
$i++;
} }
} }
?>
if (!$columns) {
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . mysql_error()) . ".</p>\n";
} else {
echo "<form action='' id='form'>\n<fieldset><legend>" . lang('Search') . "</legend>\n";
if (strlen($_GET["server"])) {
echo '<input type="hidden" name="server" value="' . htmlspecialchars($_GET["server"]) . '" />';
}
echo '<input type="hidden" name="db" value="' . htmlspecialchars($_GET["db"]) . '" />';
echo '<input type="hidden" name="select" value="' . htmlspecialchars($_GET["select"]) . '" />';
echo "\n";
$where = array();
$operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IS NULL");
$i = 0;
foreach ((array) $_GET["where"] as $val) {
if ($val["col"] && in_array($val["op"], $operators)) {
$where[] = idf_escape($val["col"]) . " $val[op]" . ($val["op"] != "IS NULL" ? " '" . mysql_real_escape_string($val["val"]) . "'" : "");
echo "<div><select name='where[$i][col]'><option></option>" . optionlist($columns, $val["col"], "not_vals") . "</select>";
echo "<select name='where[$i][op]' onchange=\"where_change(this);\">" . optionlist($operators, $val["op"], "not_vals") . "</select>";
echo "<input name='where[$i][val]' value=\"" . htmlspecialchars($val["val"]) . "\" /></div>\n";
$i++;
}
}
?>
<script type="text/javascript"> <script type="text/javascript">
function where_change(op) { function where_change(op) {
op.form[op.name.substr(0, op.name.length - 4) + '[val]'].style.display = (op.value == 'IS NULL' ? 'none' : ''); op.form[op.name.substr(0, op.name.length - 4) + '[val]'].style.display = (op.value == 'IS NULL' ? 'none' : '');
@ -36,100 +45,102 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
<?php } ?> <?php } ?>
</script> </script>
<?php <?php
echo "<div><select name='where[$i][col]'><option></option>" . optionlist($columns, array(), "not_vals") . "</select>"; echo "<div><select name='where[$i][col]'><option></option>" . optionlist($columns, array(), "not_vals") . "</select>";
echo "<select name='where[$i][op]' onchange=\"where_change(this);\">" . optionlist($operators, array(), "not_vals") . "</select>"; echo "<select name='where[$i][op]' onchange=\"where_change(this);\">" . optionlist($operators, array(), "not_vals") . "</select>";
echo "<input name='where[$i][val]' /></div>\n"; //! JavaScript for adding next echo "<input name='where[$i][val]' /></div>\n"; //! JavaScript for adding next
//! fulltext search //! fulltext search
echo "</fieldset>\n"; echo "</fieldset>\n";
echo "<fieldset><legend>" . lang('Sort') . "</legend>\n";
$order = array();
$i = 0;
foreach ((array) $_GET["order"] as $key => $val) {
if (in_array($val, $columns, true)) {
$desc = in_array($key, (array) $_GET["desc"]);
$order[] = idf_escape($val) . ($desc ? " DESC" : "");
echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, $val, "not_vals") . "</select>";
echo "<input type='checkbox' name='desc[]' value='$i' id='desc-$i'" . ($desc ? " checked='checked'" : "") . " /><label for='desc-$i'>" . lang('DESC') . "</label></div>\n";
$i++;
}
}
echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, array(), "not_vals") . "</select>";
echo "<input type='checkbox' name='desc[$i]' value='1' id='desc-$i' /><label for='desc-$i'>" . lang('DESC') . "</label></div>\n";
echo "</fieldset>\n";
echo "<fieldset><legend>" . lang('Limit') . "</legend>\n";
$limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30");
echo '<div><input name="limit" size="3" value="' . htmlspecialchars($limit) . '" /></div>';
echo "</fieldset>\n";
echo "<fieldset><legend>" . lang('Action') . "</legend><div><input type='submit' value='" . lang('Select') . "' /></div></fieldset>\n";
echo "</form>\n";
echo "<div style='clear: left; margin-bottom: 1em;'></div>\n";
$result = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . " OFFSET " . ($limit * $_GET["page"]) : ""));
$found_rows = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0); // space for mysql.trace_mode
if (!mysql_num_rows($result)) {
echo "<p class='message'>" . lang('No rows.') . "</p>\n";
} else {
$foreign_keys = array();
foreach (foreign_keys($_GET["select"]) as $foreign_key) {
foreach ($foreign_key[2] as $val) {
$foreign_keys[$val][] = $foreign_key;
}
}
$childs = array();
$result1 = mysql_query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . mysql_real_escape_string($_GET["db"]) . "' AND REFERENCED_TABLE_NAME = '" . mysql_real_escape_string($_GET["select"]) . "' ORDER BY ORDINAL_POSITION");
while ($row1 = mysql_fetch_assoc($result1)) {
$childs[$row1["CONSTRAINT_NAME"]][0] = $row1["TABLE_SCHEMA"];
$childs[$row1["CONSTRAINT_NAME"]][1] = $row1["TABLE_NAME"];
$childs[$row1["CONSTRAINT_NAME"]][2][] = $row1["REFERENCED_COLUMN_NAME"];
$childs[$row1["CONSTRAINT_NAME"]][3][] = $row1["COLUMN_NAME"];
}
mysql_free_result($result1);
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; echo "<fieldset><legend>" . lang('Sort') . "</legend>\n";
for ($j=0; $row = mysql_fetch_assoc($result); $j++) { $order = array();
if (!$j) { $i = 0;
echo "<thead><tr><th>" . implode("</th><th>", array_map('htmlspecialchars', array_keys($row))) . "</th><th>" . lang('Action') . "</th></tr></thead>\n"; foreach ((array) $_GET["order"] as $key => $val) {
if (in_array($val, $columns, true)) {
$desc = in_array($key, (array) $_GET["desc"]);
$order[] = idf_escape($val) . ($desc ? " DESC" : "");
echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, $val, "not_vals") . "</select>";
echo "<input type='checkbox' name='desc[]' value='$i' id='desc-$i'" . ($desc ? " checked='checked'" : "") . " /><label for='desc-$i'>" . lang('DESC') . "</label></div>\n";
$i++;
} }
echo "<tr>"; }
foreach ($row as $key => $val) { echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, array(), "not_vals") . "</select>";
if (!isset($val)) { echo "<input type='checkbox' name='desc[$i]' value='1' id='desc-$i' /><label for='desc-$i'>" . lang('DESC') . "</label></div>\n";
$val = "<i>NULL</i>"; echo "</fieldset>\n";
} else {
$val = (strlen(trim($val)) ? nl2br(htmlspecialchars($val)) : "&nbsp;"); echo "<fieldset><legend>" . lang('Limit') . "</legend>\n";
foreach ((array) $foreign_keys[$key] as $foreign_key) { $limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30");
if (count($foreign_keys[$key]) == 1 || count($foreign_key[2]) == 1) { echo '<div><input name="limit" size="3" value="' . htmlspecialchars($limit) . '" /></div>';
$val = '">' . "$val</a>"; echo "</fieldset>\n";
foreach ($foreign_key[2] as $i => $source) {
$val = "&amp;where[$i][col]=" . urlencode($foreign_key[3][$i]) . "&amp;where[$i][op]=%3D&amp;where[$i][val]=" . urlencode($row[$source]) . $val; echo "<fieldset><legend>" . lang('Action') . "</legend><div><input type='submit' value='" . lang('Select') . "' /></div></fieldset>\n";
echo "</form>\n";
echo "<div style='clear: left; margin-bottom: 1em;'></div>\n";
$result = mysql_query("SELECT SQL_CALC_FOUND_ROWS " . implode(", ", array_map('idf_escape', $columns)) . " FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . " OFFSET " . ($limit * $_GET["page"]) : ""));
if (!mysql_num_rows($result)) {
echo "<p class='message'>" . lang('No rows.') . "</p>\n";
} else {
$found_rows = mysql_result(mysql_query(" SELECT FOUND_ROWS()"), 0); // space for mysql.trace_mode
$indexes = indexes($_GET["select"]);
$foreign_keys = array();
foreach (foreign_keys($_GET["select"]) as $foreign_key) {
foreach ($foreign_key[2] as $val) {
$foreign_keys[$val][] = $foreign_key;
}
}
$childs = array();
$result1 = mysql_query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . mysql_real_escape_string($_GET["db"]) . "' AND REFERENCED_TABLE_NAME = '" . mysql_real_escape_string($_GET["select"]) . "' ORDER BY ORDINAL_POSITION");
while ($row1 = mysql_fetch_assoc($result1)) {
$childs[$row1["CONSTRAINT_NAME"]][0] = $row1["TABLE_SCHEMA"];
$childs[$row1["CONSTRAINT_NAME"]][1] = $row1["TABLE_NAME"];
$childs[$row1["CONSTRAINT_NAME"]][2][] = $row1["REFERENCED_COLUMN_NAME"];
$childs[$row1["CONSTRAINT_NAME"]][3][] = $row1["COLUMN_NAME"];
}
mysql_free_result($result1);
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
for ($j=0; $row = mysql_fetch_assoc($result); $j++) {
if (!$j) {
echo "<thead><tr><th>" . implode("</th><th>", array_map('htmlspecialchars', array_keys($row))) . "</th><th>" . lang('Action') . "</th></tr></thead>\n";
}
echo "<tr>";
foreach ($row as $key => $val) {
if (!isset($val)) {
$val = "<i>NULL</i>";
} else {
$val = (strlen(trim($val)) ? nl2br(htmlspecialchars($val)) : "&nbsp;");
foreach ((array) $foreign_keys[$key] as $foreign_key) {
if (count($foreign_keys[$key]) == 1 || count($foreign_key[2]) == 1) {
$val = '">' . "$val</a>";
foreach ($foreign_key[2] as $i => $source) {
$val = "&amp;where[$i][col]=" . urlencode($foreign_key[3][$i]) . "&amp;where[$i][op]=%3D&amp;where[$i][val]=" . urlencode($row[$source]) . $val;
}
$val = '<a href="' . htmlspecialchars(strlen($foreign_key[0]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key[0]), $SELF) : $SELF) . 'select=' . htmlspecialchars($foreign_key[1]) . $val; // InnoDB support non-UNIQUE keys
break;
} }
$val = '<a href="' . htmlspecialchars(strlen($foreign_key[0]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key[0]), $SELF) : $SELF) . 'select=' . htmlspecialchars($foreign_key[1]) . $val; // InnoDB support non-UNIQUE keys
break;
} }
} }
echo "<td>$val</td>";
} }
echo "<td>$val</td>"; echo '<td><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . implode('&amp;', unique_idf($row, $indexes)) . '">' . lang('edit') . '</a>'; //! views can be unupdatable
} foreach ($childs as $child) {
echo '<td><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . implode('&amp;', unique_idf($row, $indexes)) . '">' . lang('edit') . '</a>'; //! views can be unupdatable echo ' <a href="' . htmlspecialchars(strlen($child[0]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($child[0]), $SELF) : $SELF) . 'select=' . urlencode($child[1]);
foreach ($childs as $child) { foreach ($child[2] as $i => $source) {
echo ' <a href="' . htmlspecialchars(strlen($child[0]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($child[0]), $SELF) : $SELF) . 'select=' . urlencode($child[1]); echo "&amp;where[$i][col]=" . urlencode($child[3][$i]) . "&amp;where[$i][op]=%3D&amp;where[$i][val]=" . urlencode($row[$source]);
foreach ($child[2] as $i => $source) { }
echo "&amp;where[$i][col]=" . urlencode($child[3][$i]) . "&amp;where[$i][op]=%3D&amp;where[$i][val]=" . urlencode($row[$source]); echo '">' . htmlspecialchars($child[1]) . '</a>';
} }
echo '">' . htmlspecialchars($child[1]) . '</a>'; echo "</td>";
echo "</tr>\n";
} }
echo "</td>"; echo "</table>\n";
echo "</tr>\n"; if (intval($limit) && $found_rows > $limit) {
} echo "<p>" . lang('Page') . ":\n";
echo "</table>\n"; for ($i=0; $i < $found_rows / $limit; $i++) {
if (intval($limit) && $found_rows > $limit) { echo ($i == $_GET["page"] ? $i + 1 : '<a href="' . htmlspecialchars(preg_replace('~(\\?)page=[^&]*&|&page=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]) . ($i ? "&page=$i" : "")) . '">' . ($i + 1) . "</a>") . "\n";
echo "<p>" . lang('Page') . ":\n"; }
for ($i=0; $i < $found_rows / $limit; $i++) { echo "</p>\n";
echo ($i == $_GET["page"] ? $i + 1 : '<a href="' . htmlspecialchars(preg_replace('~(\\?)page=[^&]*&|&page=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]) . ($i ? "&page=$i" : "")) . '">' . ($i + 1) . "</a>") . "\n";
} }
echo "</p>\n";
} }
mysql_free_result($result);
} }
mysql_free_result($result);

View file

@ -2,34 +2,38 @@
page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"])); page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"]));
$result = mysql_query("SHOW COLUMNS FROM " . idf_escape($_GET["table"])); $result = mysql_query("SHOW COLUMNS FROM " . idf_escape($_GET["table"]));
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; if (!$result) {
while ($row = mysql_fetch_assoc($result)) { echo "<p class='error'>" . lang('Unable to show the table definition') . ": " . mysql_error() . ".</p>\n";
echo "<tr><th>" . htmlspecialchars($row["Field"]) . "</th><td>$row[Type]" . ($row["Null"] == "NO" ? "" : " <i>NULL</i>") . "</td></tr>\n"; } else {
}
echo "</table>\n";
mysql_free_result($result);
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . "</a></p>\n";
echo "<h3>" . lang('Indexes') . "</h3>\n";
$indexes = indexes($_GET["table"]);
if ($indexes) {
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
foreach ($indexes as $index) { while ($row = mysql_fetch_assoc($result)) {
ksort($index["columns"]); echo "<tr><th>" . htmlspecialchars($row["Field"]) . "</th><td>$row[Type]" . ($row["Null"] == "NO" ? "" : " <i>NULL</i>") . "</td></tr>\n";
echo "<tr><td>$index[type]</td><td><i>" . implode("</i>, <i>", $index["columns"]) . "</i></td></tr>\n";
} }
echo "</table>\n"; echo "</table>\n";
} mysql_free_result($result);
echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n"; echo '<p><a href="' . htmlspecialchars($SELF) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . "</a></p>\n";
$foreign_keys = foreign_keys($_GET["table"]); echo "<h3>" . lang('Indexes') . "</h3>\n";
if ($foreign_keys) { $indexes = indexes($_GET["table"]);
echo "<h3>" . lang('Foreign keys') . "</h3>\n"; if ($indexes) {
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
foreach ($foreign_keys as $foreign_key) { foreach ($indexes as $index) {
echo "<tr><td><em>" . implode("</em>, <em>", $foreign_key[2]) . "</em></td><td>" . (strlen($foreign_key[0]) && $foreign_key[0] !== $_GET["db"] ? "<strong>" . htmlspecialchars($foreign_key[0]) . "</strong>." : "") . htmlspecialchars($foreign_key[1]) . "(<em>" . implode("</em>, <em>", $foreign_key[3]) . "</em>)</td></tr>\n"; ksort($index["columns"]);
echo "<tr><td>$index[type]</td><td><i>" . implode("</i>, <i>", $index["columns"]) . "</i></td></tr>\n";
}
echo "</table>\n";
}
echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n";
$foreign_keys = foreign_keys($_GET["table"]);
if ($foreign_keys) {
echo "<h3>" . lang('Foreign keys') . "</h3>\n";
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
foreach ($foreign_keys as $foreign_key) {
echo "<tr><td><em>" . implode("</em>, <em>", $foreign_key[2]) . "</em></td><td>" . (strlen($foreign_key[0]) && $foreign_key[0] !== $_GET["db"] ? "<strong>" . htmlspecialchars($foreign_key[0]) . "</strong>." : "") . htmlspecialchars($foreign_key[1]) . "(<em>" . implode("</em>, <em>", $foreign_key[3]) . "</em>)</td></tr>\n";
}
echo "</table>\n";
} }
echo "</table>\n";
} }
if (mysql_get_server_info() >= 5) { if (mysql_get_server_info() >= 5) {