DbQuery: Support not equal comparisons with arrays

This commit is contained in:
Johannes Meyer 2015-11-05 15:49:15 +01:00
parent ff61b8e696
commit 1e35a17ec1
1 changed files with 8 additions and 3 deletions

View File

@ -288,9 +288,14 @@ class DbQuery extends SimpleQuery
$expression = $this->valueToTimestamp($expression);
}
if (is_array($expression) && $sign === '=') {
// TODO: Should we support this? Doesn't work for blub*
return $col . ' IN (' . $this->escapeForSql($expression) . ')';
if (is_array($expression)) {
if ($sign === '=') {
return $col . ' IN (' . $this->escapeForSql($expression) . ')';
} elseif ($sign === '!=') {
return $col . ' NOT IN (' . $this->escapeForSql($expression) . ')';
}
throw new QueryException('Unable to render array expressions with operators other than equal or not equal');
} elseif ($sign === '=' && strpos($expression, '*') !== false) {
if ($expression === '*') {
// We'll ignore such filters as it prevents index usage and because "*" means anything, anything means