]> git.joonet.de Git - adminer.git/commitdiff
Relative date and time functions
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 31 May 2009 20:07:32 +0000 (20:07 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 31 May 2009 20:07:32 +0000 (20:07 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@633 7c3ca157-0c34-0410-bff1-cbf682f78f5c

changes.txt
include/editing.inc.php

index 6f57ba2c40a92318ec6bd428e3ba1d4685bb9573..6e10d81381a78eed13b129bcf62b2e5dfd4fd041 100644 (file)
@@ -1,6 +1,7 @@
 phpMinAdmin 1.11.0:
 Connection through socket by server :/path/to/socket
 Display execution time in SQL query
+Relative date and time functions
 Version checker
 Separate JavaScript functions
 Always use the default style before the external one
index d71228f3d00698dd79da992471db3f508014fca7..61bafca605e3a408034ab43c0bd7f1a33ac59598 100644 (file)
@@ -25,14 +25,24 @@ function input($name, $field, $value, $separator = "</td><td>") { //! pass empty
                        if (preg_match('~char|date|time~', $field["type"])) {
                                $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
                        }
-                       if (!isset($_GET["clone"]) && !isset($_GET["call"]) && preg_match('~int|float|double|decimal~', $field["type"])) {
-                               $options = array("", "+", "-");
+                       if (!isset($_GET["clone"]) && !isset($_GET["call"])) {
+                               if (preg_match('~int|float|double|decimal~', $field["type"])) {
+                                       $options = array("", "+", "-");
+                               }
+                               if (preg_match('~date~', $field["type"])) {
+                                       $options[] = "+ interval";
+                                       $options[] = "- interval";
+                               }
+                               if (preg_match('~time~', $field["type"])) {
+                                       $options[] = "addtime";
+                                       $options[] = "subtime";
+                               }
                        }
                }
                if ($field["null"] || isset($_GET["default"])) {
                        array_unshift($options, "NULL");
                }
-               echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']" tabindex="1">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') . '</option>' : '') . optionlist($options, (isset($value) ? (string) $_POST["function"][$name] : null)) . '</select>' : "") . $separator;
+               echo (count($options) > 1 || isset($_GET["select"]) ? '<select name="function[' . $name . ']">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') . '</option>' : '') . optionlist($options, (isset($value) ? (string) $_POST["function"][$name] : null)) . '</select>' : "") . $separator;
                if ($field["type"] == "set") { //! 64 bits
                        preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
                        foreach ($matches[1] as $i => $val) {
@@ -74,8 +84,12 @@ function process_input($name, $field) {
                return $value;
        } elseif (preg_match('~^(now|uuid)$~', $function)) {
                return "$function()";
-       } elseif (preg_match('~^(\\+|-)$~', $function)) {
+       } elseif (preg_match('~^[+-]$~', $function)) {
                return idf_escape($name) . " $function '" . $dbh->escape_string($value) . "'";
+       } elseif (preg_match('~^[+-] interval$~', $function)) {
+               return idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : "'" . $dbh->escape_string($value) . "'") . "";
+       } elseif (preg_match('~^(addtime|subtime)$~', $function)) {
+               return "$function(" . idf_escape($name) . ", '" . $dbh->escape_string($value) . "')";
        } elseif (preg_match('~^(md5|sha1|password)$~', $function)) {
                return "$function('" . $dbh->escape_string($value) . "')";
        } else {