BUGFIX Allow PartialMatchFilter to use an array as search term

This commit is contained in:
Stig Lindqvist 2012-02-15 11:42:29 +01:00
parent abfa16fa70
commit 5d7aa8f35a

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