Skip to content

Commit

Permalink
Merge pull request #73 from kolorafa/master
Browse files Browse the repository at this point in the history
When using column search field it wrongly uses OR in place of AND
  • Loading branch information
tigrang committed Jul 6, 2017
2 parents ff3b2d5 + 0bcd332 commit b3e8d0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Controller/Component/DataTableComponent.php
Expand Up @@ -149,7 +149,7 @@ protected function _search(DataTableConfig $config, Model $Model) {
$columnSearchTerm = Hash::get($params, $searchKey);

if ($searchTerm && ($searchable === true || $searchable === DataTableConfig::SEARCH_GLOBAL)) {
$conditions[] = array("$column LIKE" => '%' . $searchTerm . '%');
$conditions['OR'][] = array("$column LIKE" => '%' . $searchTerm . '%');
}
if ($columnSearchTerm && ($searchable === true || $searchable === DataTableConfig::SEARCH_COLUMN)) {
$conditions[] = array("$column LIKE" => '%' . $columnSearchTerm . '%');
Expand All @@ -161,7 +161,7 @@ protected function _search(DataTableConfig $config, Model $Model) {
$i++;
}
if (!empty($conditions)) {
$config->conditions['OR'] = Hash::merge((array) Hash::get($config->conditions, 'OR'), $conditions);
$config->conditions['AND'] = Hash::merge((array) Hash::get($config->conditions, 'AND'), $conditions);
}
}

Expand Down

0 comments on commit b3e8d0a

Please sign in to comment.