Skip to content

Commit

Permalink
When using column search field it wrongly uses OR in place of AND
Browse files Browse the repository at this point in the history
Global single search field - search columns with OR
Column search fields - search with AND
  • Loading branch information
kolorafa_nstacja committed Apr 6, 2016
1 parent ff3b2d5 commit 0bcd332
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 0bcd332

Please sign in to comment.