From 5ea2f33efb7d3d5f811480a24eaf675d93463ba8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 16 Nov 2014 17:08:50 +0100 Subject: [PATCH] Db\DbQuery: add NOT LIKE support --- library/Icinga/Data/Db/DbQuery.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index d7cca4d85..a7cf514e2 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -251,10 +251,12 @@ class DbQuery extends SimpleQuery if (is_array($expression) && $sign === '=') { // TODO: Should we support this? Doesn't work for blub* return $col . ' IN (' . $this->escapeForSql($expression) . ')'; - } elseif (strpos($expression, '*') === false) { - return $col . ' ' . $sign . ' ' . $this->escapeForSql($expression); - } else { + } elseif ($sign === '=' && strpos($expression, '*') !== false) { return $col . ' LIKE ' . $this->escapeForSql($this->escapeWildcards($expression)); + } elseif ($sign === '!=' && strpos($expression, '*') !== false) { + return $col . ' NOT LIKE ' . $this->escapeForSql($this->escapeWildcards($expression)); + } else { + return $col . ' ' . $sign . ' ' . $this->escapeForSql($expression); } }