diff --git a/adminer/create.inc.php b/adminer/create.inc.php
index 5ff58c7e..15da283f 100644
--- a/adminer/create.inc.php
+++ b/adminer/create.inc.php
@@ -37,6 +37,11 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
$type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
if (strlen($field["field"])) {
if ($type_field) {
+ $default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
+ if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
+ $field["on_update"] = "CURRENT_TIMESTAMP";
+ $field["default"] = $default;
+ }
if (!$field["has_default"]) {
$field["default"] = null;
}
diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php
index 79509487..0bb59de4 100644
--- a/adminer/include/editing.inc.php
+++ b/adminer/include/editing.inc.php
@@ -100,10 +100,8 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
| " size="3">
| (' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '';
+ echo ($unsigned ? " ' : '');
}
function process_length($length) {
@@ -112,7 +110,7 @@ function process_length($length) {
}
function process_type($field, $collate = "COLLATE") {
- global $connection, $enum_length, $unsigned;
+ global $connection, $unsigned;
return " $field[type]"
. (strlen($field["length"]) && !ereg('^date|time$', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "")
. (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
@@ -122,10 +120,10 @@ function process_type($field, $collate = "COLLATE") {
function process_field($field, $type_field) {
global $connection;
- $default = $field["default"] . ($field["on_update"] ? " ON UPDATE $field[on_update]" : "");
return idf_escape($field["field"]) . process_type($type_field)
. ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
- . (!isset($field["default"]) || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $default) ? $default : $connection->quote($default)))
+ . (!isset($field["default"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP$", $field["default"]) ? $field["default"] : $connection->quote($field["default"])))
+ . ($field["on_update"] ? " ON UPDATE $field[on_update]" : "")
. " COMMENT " . $connection->quote($field["comment"])
;
}
diff --git a/adminer/include/mysql.inc.php b/adminer/include/mysql.inc.php
index 250db857..ac78e6f6 100644
--- a/adminer/include/mysql.inc.php
+++ b/adminer/include/mysql.inc.php
@@ -223,7 +223,7 @@ function fields($table) {
"default" => (strlen($row["Default"]) || ereg("char", $match[1]) ? $row["Default"] : null),
"null" => ($row["Null"] == "YES"),
"auto_increment" => ($row["Extra"] == "auto_increment"),
- "on_update" => (preg_match('~^on update (.+)~', $row["Extra"], $match) ? $match[1] : ""),
+ "on_update" => (eregi('^on update (.+)', $row["Extra"], $match) ? $match[1] : ""), //! available since MySQL 5.1.23
"collation" => $row["Collation"],
"privileges" => array_flip(explode(",", $row["Privileges"])),
"comment" => $row["Comment"],
diff --git a/adminer/procedure.inc.php b/adminer/procedure.inc.php
index a9e68652..1d42eaba 100644
--- a/adminer/procedure.inc.php
+++ b/adminer/procedure.inc.php
@@ -42,7 +42,7 @@ if ($_POST) {
|