Order of columns in table
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@397 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
478e9c82c5
commit
fd8948ffa0
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
if ($mysql->query("DROP TABLE " . idf_escape($_GET["create"]))) {
|
if ($mysql->query("DROP TABLE " . idf_escape($_GET["create"]))) {
|
||||||
redirect(substr($SELF, 0, -1), lang('Table has been dropped.'));
|
redirect(substr($SELF, 0, -1), lang('Table has been dropped.'));
|
||||||
|
@ -29,7 +29,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
||||||
. ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
|
. ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
|
||||||
. ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
|
. ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
|
||||||
. " COMMENT '" . $mysql->escape_string($field["comment"]) . "'"
|
. " COMMENT '" . $mysql->escape_string($field["comment"]) . "'"
|
||||||
. (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "")
|
. (strlen($_GET["create"]) ? " $after" : "")
|
||||||
;
|
;
|
||||||
$after = "AFTER " . idf_escape($field["field"]);
|
$after = "AFTER " . idf_escape($field["field"]);
|
||||||
} elseif (strlen($field["orig"])) {
|
} elseif (strlen($field["orig"])) {
|
||||||
|
@ -67,11 +67,7 @@ $result->free();
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$row = $_POST;
|
$row = $_POST;
|
||||||
ksort($row["fields"]);
|
process_fields($row["fields"]);
|
||||||
$row["fields"] = array_values($row["fields"]);
|
|
||||||
if ($_POST["add"]) {
|
|
||||||
array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
|
|
||||||
}
|
|
||||||
if ($row["auto_increment_col"]) {
|
if ($row["auto_increment_col"]) {
|
||||||
$row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;
|
$row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
|
||||||
<td><input type="radio" name="auto_increment_col" value="" /><?php echo lang('Auto Increment'); ?></td>
|
<td><input type="radio" name="auto_increment_col" value="" /><?php echo lang('Auto Increment'); ?></td>
|
||||||
<td><?php echo lang('Comment'); ?></td>
|
<td><?php echo lang('Comment'); ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td><input type="submit" name="add[0]" value="<?php echo lang('Add next'); ?>" /></td>
|
<td><input type="submit" name="add[0]" value="+" title="<?php echo lang('Add next'); ?>" /></td>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<?php
|
<?php
|
||||||
$column_comments = false;
|
$column_comments = false;
|
||||||
|
@ -111,7 +111,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
|
||||||
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
|
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
|
||||||
<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
|
<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /> <input type="submit" name="drop_col[<?php echo $i; ?>]" value="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" /></td>
|
<td style="white-space: nowrap;"><input type="submit" name="add[<?php echo $i; ?>]" value="+" title="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /> <input type="submit" name="drop_col[<?php echo $i; ?>]" value="-" title="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" /> <input type="submit" name="up[<?php echo $i; ?>]" value="↑" title="<?php echo lang('Move up'); ?>" /> <input type="submit" name="down[<?php echo $i; ?>]" value="↓" title="<?php echo lang('Move down'); ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
if (strlen($field["comment"])) {
|
if (strlen($field["comment"])) {
|
||||||
|
@ -121,6 +121,43 @@ function edit_fields($fields, $collations, $type = "TABLE") {
|
||||||
return $column_comments;
|
return $column_comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function process_fields(&$fields) {
|
||||||
|
ksort($fields);
|
||||||
|
$offset = 0;
|
||||||
|
if ($_POST["up"]) {
|
||||||
|
$last = 0;
|
||||||
|
foreach ($fields as $key => $field) {
|
||||||
|
if (key($_POST["up"]) == $key) {
|
||||||
|
unset($fields[$key]);
|
||||||
|
array_splice($fields, $last, 0, array($field));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (isset($field["field"])) {
|
||||||
|
$last = $offset;
|
||||||
|
}
|
||||||
|
$offset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($_POST["down"]) {
|
||||||
|
$found = false;
|
||||||
|
foreach ($fields as $key => $field) {
|
||||||
|
if (isset($field["field"]) && $found) {
|
||||||
|
unset($fields[key($_POST["down"])]);
|
||||||
|
array_splice($fields, $offset, 0, array($found));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (key($_POST["down"]) == $key) {
|
||||||
|
$found = $field;
|
||||||
|
}
|
||||||
|
$offset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$fields = array_values($fields);
|
||||||
|
if ($_POST["add"]) {
|
||||||
|
array_splice($fields, key($_POST["add"]), 0, array(array()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function type_change($count) {
|
function type_change($count) {
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
||||||
|
|
||||||
$dropped = false;
|
$dropped = false;
|
||||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||||
if (strlen($_GET["procedure"]) && ($_POST["dropped"] || $mysql->query("DROP $routine " . idf_escape($_GET["procedure"])))) {
|
if (strlen($_GET["procedure"]) && ($_POST["dropped"] || $mysql->query("DROP $routine " . idf_escape($_GET["procedure"])))) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
redirect(substr($SELF, 0, -1), lang('Routine has been dropped.'));
|
redirect(substr($SELF, 0, -1), lang('Routine has been dropped.'));
|
||||||
|
@ -35,11 +35,7 @@ $collations = get_vals("SHOW CHARACTER SET");
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$row = $_POST;
|
$row = $_POST;
|
||||||
$row["fields"] = (array) $row["fields"];
|
$row["fields"] = (array) $row["fields"];
|
||||||
ksort($row["fields"]);
|
process_fields($row["fields"]);
|
||||||
$row["fields"] = array_values($row["fields"]);
|
|
||||||
if ($_POST["add"]) {
|
|
||||||
array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
|
|
||||||
}
|
|
||||||
} elseif (strlen($_GET["procedure"])) {
|
} elseif (strlen($_GET["procedure"])) {
|
||||||
$row = routine($_GET["procedure"], $routine);
|
$row = routine($_GET["procedure"], $routine);
|
||||||
$row["name"] = $_GET["procedure"];
|
$row["name"] = $_GET["procedure"];
|
||||||
|
|
1
todo.txt
1
todo.txt
|
@ -1,6 +1,5 @@
|
||||||
Edit of fields with foreign key as <select> (optional)
|
Edit of fields with foreign key as <select> (optional)
|
||||||
Highlight found fields
|
Highlight found fields
|
||||||
Order of columns in table
|
|
||||||
MySQL 5 BIT data type
|
MySQL 5 BIT data type
|
||||||
Check MySQL server version
|
Check MySQL server version
|
||||||
Rename table to other database
|
Rename table to other database
|
||||||
|
|
Loading…
Reference in a new issue