# improving of the negated search criteria behavior

This commit is contained in:
Klaus Leithoff 2008-06-17 07:28:35 +00:00
parent 4167181289
commit 09abb185f9

View File

@ -661,12 +661,14 @@ class so_sql
is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false)) is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false))
{ {
$cmp_op = ' '.$this->db->capabilities['case_insensitive_like'].' '; $cmp_op = ' '.$this->db->capabilities['case_insensitive_like'].' ';
$negate = false;
if ($criteria[$col][0] == '!') if ($criteria[$col][0] == '!')
{ {
$cmp_op = ' NOT'.$cmp_op; $cmp_op = ' NOT'.$cmp_op;
$criteria[$col] = substr($criteria[$col],1); $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 elseif (strpos($db_col,'.')!==false) // we have a table-name specified
{ {