From fd8948ffa0dac6aeca652ae16891f673bff5b405 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Wed, 7 May 2008 11:22:08 +0000 Subject: [PATCH] Order of columns in table git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@397 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- create.inc.php | 10 +++------- editing.inc.php | 41 +++++++++++++++++++++++++++++++++++++++-- procedure.inc.php | 8 ++------ todo.txt | 1 - 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/create.inc.php b/create.inc.php index 005bec36..73f378ca 100644 --- a/create.inc.php +++ b/create.inc.php @@ -1,5 +1,5 @@ query("DROP TABLE " . idf_escape($_GET["create"]))) { 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 . ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "") . " COMMENT '" . $mysql->escape_string($field["comment"]) . "'" - . (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "") + . (strlen($_GET["create"]) ? " $after" : "") ; $after = "AFTER " . idf_escape($field["field"]); } elseif (strlen($field["orig"])) { @@ -67,11 +67,7 @@ $result->free(); if ($_POST) { $row = $_POST; - ksort($row["fields"]); - $row["fields"] = array_values($row["fields"]); - if ($_POST["add"]) { - array_splice($row["fields"], key($_POST["add"]), 0, array(array())); - } + process_fields($row["fields"]); if ($row["auto_increment_col"]) { $row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true; } diff --git a/editing.inc.php b/editing.inc.php index 904212b2..e7f4d048 100644 --- a/editing.inc.php +++ b/editing.inc.php @@ -94,7 +94,7 @@ function edit_fields($fields, $collations, $type = "TABLE") { - + checked="checked" /> " maxlength="255" /> - + $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) { ?>