Skip to content

Commit

Permalink
Prepare for index edit
Browse files Browse the repository at this point in the history
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@27 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information
jakubvrana committed Jul 4, 2007
1 parent 77dfca8 commit 88e1daf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion create.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
} else {
$row = array("fields" => array());
}
//! collate columns, references, indexes, unsigned, zerofill, default
//! collate columns, references, unsigned, zerofill, default
?>
<form action="" method="post">
<p>
Expand Down
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
include "./edit.inc.php";
} elseif (isset($_GET["create"])) {
include "./create.inc.php";
} elseif (isset($_GET["indexes"])) {
include "./indexes.inc.php";
} elseif (isset($_GET["dump"])) {
include "./dump.inc.php";
} elseif (isset($_GET["view"])) {
Expand Down
38 changes: 38 additions & 0 deletions indexes.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
$index_types = array("PRIMARY", "UNIQUE", "INDEX", "FULLTEXT");
if ($_POST) {
}

page_header(lang('Indexes') . ': ' . htmlspecialchars($_GET["indexes"]));
echo "<h2>" . lang('Indexes') . ': ' . htmlspecialchars($_GET["indexes"]) . "</h2>\n";

if ($_POST) {
echo "<p class='error'>" . lang('Unable to operate indexes') . ": " . htmlspecialchars($error) . "</p>\n";
$row = $_POST;
} else {
$row = array("indexes" => indexes($_GET["indexes"]));
}
?>
<form action="" method="post">
<table border="0" cellspacing="0" cellpadding="2">
<?php
$fields = array_keys(fields($_GET["indexes"]));
$j = 0;
foreach ($row["indexes"] as $type => $index) {
foreach ($index as $columns) {
echo "<tr><td><select name='indexes[$j][type]'><option></option>" . optionlist($index_types, $type, "not_vals") . "</select></td><td>";
sort($columns);
foreach ($columns as $i => $column) {
echo "<select name='indexes[$j][columns][$i]'><option></option>" . optionlist($fields, $column, "not_vals") . "</select>";
}
echo "<select name='indexes[$j][columns][" . ($i+1) . "]'><option></option>" . optionlist($fields, array(), "not_vals") . "</select>";
echo "</td></tr>\n";
$j++;
}
}
//! JavaScript for adding more indexes and columns
?>
<tr><td><select name="indexes[<?php echo $j; ?>][type]"><option></option><?php echo optionlist($index_types, array(), "not_vals"); ?></select></td><td><select name="indexes[<?php echo $j; ?>][columns][1]"><option></option><?php echo optionlist($fields, array(), "not_vals"); ?></select></td></tr>
</table>
<p><input type="submit" value="<?php echo lang('Alter indexes'); ?>" /></p>
</form>
3 changes: 2 additions & 1 deletion table.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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 "<h3>" . lang('Indexes') . "</h3>\n";
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
foreach ($indexes as $type => $index) {
foreach ($index as $columns) {
Expand All @@ -23,6 +23,7 @@
}
echo "</table>\n";
}
echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n";

$result = mysql_query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . mysql_real_escape_string($_GET["db"]) . "' AND TABLE_NAME = '" . mysql_real_escape_string($_GET["table"]) . "' AND REFERENCED_TABLE_NAME IS NOT NULL ORDER BY ORDINAL_POSITION");
if (mysql_num_rows($result)) {
Expand Down

0 comments on commit 88e1daf

Please sign in to comment.