Merge pull request #199 from silverstripe-scienceninjas/pull/partialmatch-array-values

BUGFIX Allow PartialMatchFilter to use an array as search term
This commit is contained in:
Sam Minnée 2012-02-23 19:14:36 -08:00
commit dc439ed0e2

View File

@ -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() {