Skip to content
Browse files

Merge pull request #199 from silverstripe-scienceninjas/pull/partialm…

…atch-array-values

BUGFIX Allow PartialMatchFilter to use an array as search term
  • Loading branch information...
2 parents 61c810a + 5d7aa8f commit dc439ed0e2e9e81cc2310d4085853451fa5e0bc7 @sminnee sminnee committed
Showing with 11 additions and 5 deletions.
  1. +11 −5 search/filters/PartialMatchFilter.php
View
16 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() {

0 comments on commit dc439ed

Please sign in to comment.
Something went wrong with that request. Please try again.