]> git.joonet.de Git - adminer.git/commitdiff
Use NOW for timestamp edit (thanks to paranoiq)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 13 Jul 2009 16:33:54 +0000 (16:33 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 13 Jul 2009 16:33:54 +0000 (16:33 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@814 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/call.inc.php
adminer/edit.inc.php
adminer/include/functions.inc.php
adminer/include/mysql.inc.php

index 5d2e1475687e159135e5359e9b63f9b679e11aa1..cc4666a75f2b7440c514913698af324e8c21792f 100644 (file)
@@ -57,7 +57,7 @@ if ($in) {
                if (strlen($value) && ($field["type"] == "enum" || $field["type"] == "set")) {
                        $value = intval($value);
                }
-               input($key, $field, $value); // param name can be empty
+               input($key, $field, $value, (string) $_POST["function"][$name]); // param name can be empty
                echo "\n";
        }
        echo "</table>\n";
index 40ca0081900d5196cce9c2432a1b13084ee55d26..c94a824c6098a427587dc3112969d258fe448202 100644 (file)
@@ -78,7 +78,8 @@ if ($fields) {
                        ? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
                        : ($_POST["clone"] && $field["auto_increment"] ? "" : ($where ? $field["default"] : false))
                );
-               input($name, $field, $value);
+               $function = ($_POST["save"] ? (string) $_POST["function"][$name] : ($field[($where ? "on_update" : "default")] == "CURRENT_TIMESTAMP" ? "now" : ($value === false ? null : (isset($value) ? '' : 'NULL'))));
+               input($name, $field, $value, $function);
                if (isset($_GET["default"]) && $field["type"] == "timestamp") {
                        if (!isset($create) && !$_POST) {
                                //! disable sql_mode NO_FIELD_OPTIONS
index 4b34ffe6bb8f311cee20039132c66b7f51acdc4e..791dca3669150a8530a97b7ffd33a6d498486094 100644 (file)
@@ -257,7 +257,7 @@ function hidden_fields($process, $ignore = array()) {
        }
 }
 
-function input($name, $field, $value) {
+function input($name, $field, $value, $function) {
        global $types;
        $name = htmlspecialchars(bracket_escape($name));
        echo "<td class='function'>";
@@ -301,7 +301,7 @@ function input($name, $field, $value) {
                if ($field["null"] || isset($_GET["default"])) {
                        array_unshift($options, "NULL");
                }
-               echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') : '') . optionlist($options, ($value === false ? null : (isset($value) ? (string) $_POST["function"][$name] : 'NULL'))) . '</select>' : "&nbsp;") . '<td>';
+               echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') : '') . optionlist($options, $function) . '</select>' : "&nbsp;") . '<td>';
                if ($field["type"] == "set") { //! 64 bits
                        preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
                        foreach ($matches[1] as $i => $val) {
index e55614a301fd23b8ef027cced49e6f66f1412f1e..eecba2f63d716162bc44855c50a7e9b45ef037b6 100644 (file)
@@ -262,6 +262,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] : ""),
                                "collation" => $row["Collation"],
                                "privileges" => array_flip(explode(",", $row["Privileges"])),
                                "comment" => $row["Comment"],