Skip to content

Commit b3e8d0a

Browse files
authored
Merge pull request #73 from kolorafa/master
When using column search field it wrongly uses OR in place of AND
2 parents ff3b2d5 + 0bcd332 commit b3e8d0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Controller/Component/DataTableComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function _search(DataTableConfig $config, Model $Model) {
149149
$columnSearchTerm = Hash::get($params, $searchKey);
150150

151151
if ($searchTerm && ($searchable === true || $searchable === DataTableConfig::SEARCH_GLOBAL)) {
152-
$conditions[] = array("$column LIKE" => '%' . $searchTerm . '%');
152+
$conditions['OR'][] = array("$column LIKE" => '%' . $searchTerm . '%');
153153
}
154154
if ($columnSearchTerm && ($searchable === true || $searchable === DataTableConfig::SEARCH_COLUMN)) {
155155
$conditions[] = array("$column LIKE" => '%' . $columnSearchTerm . '%');
@@ -161,7 +161,7 @@ protected function _search(DataTableConfig $config, Model $Model) {
161161
$i++;
162162
}
163163
if (!empty($conditions)) {
164-
$config->conditions['OR'] = Hash::merge((array) Hash::get($config->conditions, 'OR'), $conditions);
164+
$config->conditions['AND'] = Hash::merge((array) Hash::get($config->conditions, 'AND'), $conditions);
165165
}
166166
}
167167

0 commit comments

Comments
 (0)