mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
commit
dc439ed0e2
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user