ZfQueryBasedTable: only search with wildcards...

...when no wildcard has been given
This commit is contained in:
Thomas Gelf 2018-10-30 16:42:55 +01:00
parent dce9770dcd
commit d8184ce373
1 changed files with 10 additions and 2 deletions

View File

@ -89,14 +89,22 @@ abstract class ZfQueryBasedTable extends QueryBasedTable
if (strpos($search, ' ') === false) {
$filter = Filter::matchAny();
foreach ($columns as $column) {
$filter->addFilter(Filter::expression($column, '=', "*$search*"));
if (strpos($search, '*') === false) {
$filter->addFilter(Filter::expression($column, '=', "*$search*"));
} else {
$filter->addFilter(Filter::expression($column, '=', $search));
}
}
} else {
$filter = Filter::matchAll();
foreach (explode(' ', $search) as $s) {
$sub = Filter::matchAny();
foreach ($columns as $column) {
$sub->addFilter(Filter::expression($column, '=', "*$s*"));
if (strpos($search, '*') === false) {
$sub->addFilter(Filter::expression($column, '=', "*$s*"));
} else {
$sub->addFilter(Filter::expression($column, '=', $s));
}
}
$filter->addFilter($sub);
}