]> git.joonet.de Git - adminer.git/commitdiff
Empty value in Editor as NULL
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 23 Jul 2009 16:22:50 +0000 (16:22 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 23 Jul 2009 16:22:50 +0000 (16:22 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@886 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/adminer.inc.php
adminer/include/functions.inc.php
editor/include/adminer.inc.php

index 9a0f08b1842c23878bebbddf255729d459a95672..02d4f5842728470727d6d2e4e27357019f6a5dfe 100644 (file)
@@ -166,6 +166,33 @@ function adminer_edit_input($table, $field) {
        return call_adminer('edit_input', false, $table, $field);
 }
 
+/** Process sent input
+* @param string field name
+* @param array single field from fields()
+* @return string expression to use in a query
+*/
+function adminer_process_input($name, $field) {
+       global $dbh;
+       $idf = bracket_escape($name);
+       $function = $_POST["function"][$idf];
+       $value = $_POST["fields"][$idf];
+       $return = $dbh->quote($value);
+       if (ereg('^(now|uuid)$', $function)) {
+               $return = "$function()";
+       } elseif (ereg('^[+-]$', $function)) {
+               $return = idf_escape($name) . " $function $return";
+       } elseif (ereg('^[+-] interval$', $function)) {
+               $return = idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return);
+       } elseif (ereg('^(addtime|subtime)$', $function)) {
+               $return = "$function(" . idf_escape($name) . ", $return)";
+       } elseif (ereg('^(md5|sha1|password)$', $function)) {
+               $return = "$function($return)";
+       } elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") {
+               $return = $value;
+       }
+       return call_adminer('process_input', $return, $name, $field);
+}
+
 /** Prints navigation after Adminer title
 * @param string can be "auth" if there is no database connection or "db" if there is no database selected
 * @return bool true if default navigation should be printed
index 153fa60af91abdf528a0c3bb51aa5711728659b7..677604680f218574b740d2d397d8ad629e44a18c 100644 (file)
@@ -339,20 +339,8 @@ function process_input($name, $field) {
                        return false; //! report errors
                }
                return "_binary" . $dbh->quote($file);
-       } elseif (ereg('^(now|uuid)$', $function)) {
-               return "$function()";
-       } elseif (ereg('^[+-]$', $function)) {
-               return idf_escape($name) . " $function " . $dbh->quote($value);
-       } elseif (ereg('^[+-] interval$', $function)) {
-               return idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $dbh->quote($value));
-       } elseif (ereg('^(addtime|subtime)$', $function)) {
-               return "$function(" . idf_escape($name) . ", " . $dbh->quote($value) . ")";
-       } elseif (ereg('^(md5|sha1|password)$', $function)) {
-               return "$function(" . $dbh->quote($value) . ")";
-       } elseif ($field["type"] == "timestamp" && $value == "CURRENT_TIMESTAMP") {
-               return $value;
        } else {
-               return $dbh->quote($value);
+               return adminer_process_input($name, $field);
        }
 }
 
index 27f75fe259b3bab6007f7b982a48d79c5719e8d3..b9ae9c3d62cccf7f548bfe173a98c11eb437c322 100644 (file)
@@ -146,6 +146,25 @@ function adminer_edit_input($table, $field) {
        return call_adminer('edit_input', $return, $table, $field);
 }
 
+/** Process sent input
+* @param string field name
+* @param array single field from fields()
+* @return string expression to use in a query
+*/
+function adminer_process_input($name, $field) {
+       global $dbh;
+       $idf = bracket_escape($name);
+       $function = $_POST["function"][$idf];
+       $value = $_POST["fields"][$idf];
+       $return = $dbh->quote($value);
+       if (!ereg('varchar|text', $field["type"]) && !strlen($value)) {
+               $return = "NULL";
+       } elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") {
+               $return = $value;
+       }
+       return call_adminer('process_input', $return, $name, $field);
+}
+
 function adminer_navigation($missing) {
        global $SELF;
        if (call_adminer('navigation', true, $missing) && $missing != "auth") {