From d51b260470c023fc209177a291546e036b2b100d Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 5 Jul 2007 14:36:35 +0000 Subject: [PATCH] Unsigned, column collation git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@47 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- create.inc.php | 41 +++++++++++++++++++++++++++++++---------- functions.inc.php | 7 ++++--- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/create.inc.php b/create.inc.php index bfa62657..83517d1e 100644 --- a/create.inc.php +++ b/create.inc.php @@ -1,5 +1,6 @@ $field) { if (strlen($field["field"]) && isset($types[$field["type"]])) { - $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ")) . idf_escape($field["field"]) . " $field[type]" . ($field["length"] ? "($field[length])" : "") . ($field["null"] ? "" : " NOT NULL") . ($field["extra"] == "auto_increment" ? " AUTO_INCREMENT PRIMARY KEY" : ""); + $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ")) + . idf_escape($field["field"]) . " $field[type]" + . ($field["length"] ? "($field[length])" : "") + . (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "") + . (preg_match('~char|text~', $field["type"]) && $field["collation"] ? " COLLATE '" . mysql_real_escape_string($field["collation"]) . "'" : "") + . ($field["null"] ? "" : " NOT NULL") + . ($key == $_POST["auto_increment"] ? " AUTO_INCREMENT PRIMARY KEY" : "") //! drop old primary key, can be part of any index + ; } elseif (strlen($field["orig"])) { $fields[] = "DROP " . idf_escape($field["orig"]); } @@ -42,27 +50,29 @@ if ($_POST) { } else { $row = array("fields" => array()); } -//! collate columns, references, unsigned, zerofill, default +//! default, comments +$collations = collations(); ?> -
+

: " /> - +

- + - + + - + - + + - +
" />" maxlength="64" /> " size="3" /> checked="checked" /> checked="checked" /> checked="checked" />
+

diff --git a/functions.inc.php b/functions.inc.php index cb449a2f..0ad02c65 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -31,17 +31,18 @@ function optionlist($options, $selected = array(), $not_vals = false) { function fields($table) { $return = array(); - $result = mysql_query("SHOW COLUMNS FROM " . idf_escape($table)); + $result = mysql_query("SHOW FULL COLUMNS FROM " . idf_escape($table)); while ($row = mysql_fetch_assoc($result)) { - preg_match('~^([^(]+)(?:\\((.+)\\))?( unsigned)?$~', $row["Type"], $match); + preg_match('~^([^(]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match); $return[$row["Field"]] = array( "field" => $row["Field"], "type" => $match[1], "length" => $match[2], - "unsigned" => $match[3], + "unsigned" => ltrim($match[3] . $match[4]), "default" => $row["Default"], "null" => ($row["Null"] != "NO"), "extra" => $row["Extra"], + "collation" => $row["Collation"], ); } mysql_free_result($result);