diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 37faf96a..13295e45 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -440,8 +440,7 @@ document.getElementById('username').focus();
if ($field["type"] == "enum") {
return (isset($_GET["select"]) ? " " : "")
. ($field["null"] ? " " : "")
- . ""
- . enum_input("radio", $attrs, $field, $value)
+ . enum_input("radio", $attrs, $field, $value, 0) // 0 - empty
;
}
return "";
diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php
index ed4e5194..3e2b8277 100644
--- a/adminer/include/functions.inc.php
+++ b/adminer/include/functions.inc.php
@@ -620,12 +620,13 @@ function column_foreign_keys($table) {
* @param string
* @param array
* @param mixed int|string|array
+* @param string
* @return null
*/
-function enum_input($type, $attrs, $field, $value) {
+function enum_input($type, $attrs, $field, $value, $empty = null) {
global $adminer;
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
- $return = "";
+ $return = (isset($empty) ? "" : "");
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
$checked = (is_int($value) ? $value == $i+1 : (is_array($value) ? in_array($i+1, $value) : $value === $val));
diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php
index 6d99494f..61ca6a92 100644
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -203,7 +203,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
$key = $keys[$name];
$i--;
echo "
" . h($desc) . ":";
- echo enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"]); //! impossible to search for NULL
+ echo enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"], ($field["null"] ? 0 : null));
echo "
\n";
unset($columns[$name]);
}
@@ -295,7 +295,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
if ($col != "" || is_numeric($val) || !ereg('int|float|double|decimal', $field["type"])) {
if ($col != "" && $field["type"] == "enum") {
- $conds[] = idf_escape($name) . " IN (" . implode(", ", array_map('intval', $val)) . ")";
+ $conds[] = (in_array(0, $val) ? idf_escape($name) . " IS NULL OR " : "") . idf_escape($name) . " IN (" . implode(", ", array_map('intval', $val)) . ")";
} else {
$text_type = ereg('char|text|enum|set', $field["type"]);
$value = $this->processInput($field, ($text_type && ereg('^[^%]+$', $val) ? "%$val%" : $val));
@@ -402,8 +402,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
function editInput($table, $field, $attrs, $value) {
if ($field["type"] == "enum") {
return (isset($_GET["select"]) ? " " : "")
- . ($field["null"] ? "" : "")
- . enum_input("radio", $attrs, $field, $value)
+ . enum_input("radio", $attrs, $field, ($value || isset($_GET["select"]) ? $value : 0), ($field["null"] ? "" : null))
;
}
$options = $this->_foreignKeyOptions($table, $field["field"]);