mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 18:14:07 +02:00
Selectable ON UPDATE CURRENT_TIMESTAMP field in create table
This commit is contained in:
@@ -36,11 +36,6 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||
if (!$field["has_default"]) {
|
||||
$field["default"] = null;
|
||||
}
|
||||
$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 ($key == $_POST["auto_increment_col"]) {
|
||||
$field["auto_increment"] = true;
|
||||
}
|
||||
@@ -125,9 +120,6 @@ if ($_POST) {
|
||||
}
|
||||
foreach ($orig_fields as $field) {
|
||||
$field["has_default"] = isset($field["default"]);
|
||||
if ($field["on_update"]) {
|
||||
$field["default"] .= " ON UPDATE $field[on_update]"; // CURRENT_TIMESTAMP
|
||||
}
|
||||
$row["fields"][] = $field;
|
||||
}
|
||||
if (support("partitioning")) {
|
||||
|
@@ -152,6 +152,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
|
||||
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"><td class="options"><?php //! type="number" with enabled JavaScript
|
||||
echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
||||
echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
||||
echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($field["type"] == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
|
||||
echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (ereg("`", $field["type"]) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
|
||||
}
|
||||
|
||||
@@ -189,7 +190,7 @@ function process_field($field, $type_field) {
|
||||
process_type($type_field),
|
||||
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
|
||||
(isset($field["default"]) ? " DEFAULT " . ((ereg("time", $field["type"]) && eregi('^CURRENT_TIMESTAMP$', $field["default"])) || ($field["type"] == "bit" && ereg("^([0-9]+|b'[0-1]+')\$", $field["default"])) ? $field["default"] : q($field["default"])) : ""),
|
||||
($field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
|
||||
($field["type"] == "timestamp" && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
|
||||
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
|
||||
($field["auto_increment"] ? auto_increment() : null),
|
||||
);
|
||||
|
@@ -365,6 +365,9 @@ function editingTypeChange(type) {
|
||||
if (el.name == name + '[unsigned]') {
|
||||
el.className = (/(int|float|double|decimal)$/.test(text) ? '' : 'hidden');
|
||||
}
|
||||
if (el.name == name + '[on_update]') {
|
||||
el.className = (text == 'timestamp' ? '' : 'hidden');
|
||||
}
|
||||
if (el.name == name + '[on_delete]') {
|
||||
el.className = (/`/.test(text) ? '' : 'hidden');
|
||||
}
|
||||
|
Reference in New Issue
Block a user