From 09abb185f9edcb807b74468a592cdfc94baf161c Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 17 Jun 2008 07:28:35 +0000 Subject: [PATCH] # improving of the negated search criteria behavior --- etemplate/inc/class.so_sql.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.so_sql.inc.php b/etemplate/inc/class.so_sql.inc.php index c99f76f7b9..87f1260451 100644 --- a/etemplate/inc/class.so_sql.inc.php +++ b/etemplate/inc/class.so_sql.inc.php @@ -661,12 +661,14 @@ class so_sql is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false)) { $cmp_op = ' '.$this->db->capabilities['case_insensitive_like'].' '; + $negate = false; if ($criteria[$col][0] == '!') { $cmp_op = ' NOT'.$cmp_op; $criteria[$col] = substr($criteria[$col],1); + $negate = true; } - $query[] = $db_col.$cmp_op.$this->db->quote($wildcard.str_replace(array('%','_','*','?'),array('\\%','\\_','%','_'),$criteria[$col]).$wildcard); + $query[] = ($negate ? ' ('.$db_col.' IS NULL OR ' : '').$db_col.$cmp_op.$this->db->quote($wildcard.str_replace(array('%','_','*','?'),array('\\%','\\_','%','_'),$criteria[$col]).$wildcard).($negate ? ') ' : ''); } elseif (strpos($db_col,'.')!==false) // we have a table-name specified {