From 0bcd3322bf0cd76435646f889be242ebae5dad08 Mon Sep 17 00:00:00 2001 From: kolorafa_nstacja Date: Wed, 6 Apr 2016 16:38:32 +0200 Subject: [PATCH] When using column search field it wrongly uses OR in place of AND Global single search field - search columns with OR Column search fields - search with AND --- Controller/Component/DataTableComponent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/Component/DataTableComponent.php b/Controller/Component/DataTableComponent.php index 9fef756..dee1485 100644 --- a/Controller/Component/DataTableComponent.php +++ b/Controller/Component/DataTableComponent.php @@ -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 . '%'); @@ -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); } }