mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
Support wildcard filters in chains (#3903)
This commit is contained in:
parent
2ca3ffcb60
commit
31d3153d2b
@ -298,13 +298,31 @@ class DbQuery extends SimpleQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($expression)) {
|
if (is_array($expression)) {
|
||||||
|
$comp = [];
|
||||||
|
$pattern = [];
|
||||||
|
foreach ($expression as $value) {
|
||||||
|
if (strpos($value, '*') === false) {
|
||||||
|
$comp[] = $value;
|
||||||
|
} else {
|
||||||
|
$pattern[] = $this->whereToSql($col, $sign, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql = $pattern;
|
||||||
if ($sign === '=') {
|
if ($sign === '=') {
|
||||||
return $col . ' IN (' . $this->escapeForSql($expression) . ')';
|
if (! empty($comp)) {
|
||||||
|
$sql[] = $col . ' IN (' . $this->escapeForSql($comp) . ')';
|
||||||
|
}
|
||||||
} elseif ($sign === '!=') {
|
} elseif ($sign === '!=') {
|
||||||
return sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($expression));
|
if (! empty($comp)) {
|
||||||
|
$sql[] = sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($comp));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new QueryException(
|
||||||
|
'Unable to render array expressions with operators other than equal or not equal'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new QueryException('Unable to render array expressions with operators other than equal or not equal');
|
return '(' . implode(' OR ', $sql) . ')';
|
||||||
} elseif ($sign === '=' && strpos($expression, '*') !== false) {
|
} elseif ($sign === '=' && strpos($expression, '*') !== false) {
|
||||||
if ($expression === '*') {
|
if ($expression === '*') {
|
||||||
return new Zend_Db_Expr('TRUE');
|
return new Zend_Db_Expr('TRUE');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user