From 5d7aa8f35a96ae85c86996f20edb2a7f3c7f4dac Mon Sep 17 00:00:00 2001 From: Stig Lindqvist Date: Wed, 15 Feb 2012 11:42:29 +0100 Subject: [PATCH] BUGFIX Allow PartialMatchFilter to use an array as search term --- search/filters/PartialMatchFilter.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/search/filters/PartialMatchFilter.php b/search/filters/PartialMatchFilter.php index 1894a7237..1237cefe0 100644 --- a/search/filters/PartialMatchFilter.php +++ b/search/filters/PartialMatchFilter.php @@ -14,11 +14,17 @@ class PartialMatchFilter extends SearchFilter { public function apply(DataQuery $query) { $this->model = $query->applyRelation($this->relation); - return $query->where(sprintf( - "%s LIKE '%%%s%%'", - $this->getDbName(), - Convert::raw2sql($this->getValue()) - )); + $where = array(); + if(is_array($this->getValue())) { + foreach($this->getValue() as $value) { + $where[]= sprintf("%s LIKE '%%%s%%'", $this->getDbName(), Convert::raw2sql($value)); + } + + } else { + $where[] = sprintf("%s LIKE '%%%s%%'", $this->getDbName(), Convert::raw2sql($this->getValue())); + } + + return $query->where(implode(' OR ', $where)); } public function isEmpty() {