From 37f6da9aa8df93525b87bd37968a30eb6f9a6dba Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 15:36:51 +0100 Subject: [PATCH] recovered. changes from 0b72571c7cb47056711365750f9035012ab88af6 [formerly f3a8cdd6923834443ed7223d1e6ad7776b861184] Former-commit-id: 591e002043d2bae2382c8a91c437057fd2b809c7 --- pandora_console/include/db/mysql.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 49ffb2d101..66366c1289 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -706,6 +706,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa $i = 1; $max = count($values); foreach ($values as $field => $value) { + $negative = false; if (is_numeric($field)) { // User provide the exact operation to do $query .= $value; @@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa continue; } + if ($field[0] == '!') { + $negative = true; + $field = substr($field, 1); + } + if ($field[0] != '`') { // If the field is as ., don't scape. if (strstr($field, '.') === false) { @@ -732,7 +738,8 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa } else if (is_float($value) || is_double($value)) { $query .= sprintf('%s = %f', $field, $value); } else if (is_array($value)) { - $query .= sprintf('%s IN ("%s")', $field, implode('", "', $value)); + $not = $negative ? ' NOT ' : ''; + $query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value)); } else { if ($value === '') { // Search empty string