# Paginate condition

**URL:** <https://discourse.cakephp.org/t/paginate-condition/6635>\
**Category:** Uncategorized\
**Created:** [September 19, 2019, 12:15am UTC](https://discourse.cakephp.org/t/paginate-condition/6635 "2019-09-19T00:15:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![e4hats](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@e4hats](https://discourse.cakephp.org/u/e4hats)\
**Post date:** [September 19, 2019, 12:15am UTC](https://discourse.cakephp.org/t/paginate-condition/6635/1 "2019-09-19T00:15:28Z")

</div>

Hi,

I’d like to search multiple items copied from excel. These skus are separated by empty space. Search result is always empty because each condition should be OR not AND. How can I change pagenate condition from AND to OR?

Query Result  
SELECT \*, `ParentProduct`.`id` FROM `parent_products` AS `ParentProduct` WHERE `ParentProduct`.`name` LIKE ‘%na301mo%’ AND `ParentProduct`.`name` LIKE ‘%gf001bh%’ AND `ParentProduct`.`name` LIKE ‘%cc302bf%’ LIMIT 10

search values  
na301mo gf001bh cc302bf

Controller  
if (empty($results)) {  
$this-\>paginate[‘conditions’] = $this-\>ParentProduct-\>resetConditions($searchStr, ‘multi-skus’);  
$results = $this-\>paginate(‘ParentProduct’);  
}

Model  
public function resetConditions($searchStr, $opt) {  
if ($opt == ‘multi-skus’) {  
$conditions = array();  
$searchStr = preg\_replace(’!\s+!’, ’ ‘, $searchStr);  
$search\_terms = explode(’ ', $searchStr);  
foreach ($search\_terms as $search\_term) {  
$conditions[] = array($this-\>name . ‘.sku LIKE’ =\> ‘%’ . $search\_term . ‘%’);  
}   
}  
}

Version. 1.3x

Please advise.  
Thank you

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [September 21, 2019, 11:42pm UTC](https://discourse.cakephp.org/t/paginate-condition/6635/2 "2019-09-21T23:42:49Z")

</div>

This should guide you some what in the right direction:

> [@\[RESOLVED\] Pagination does not allow query string parameters](https://discourse.cakephp.org/t/resolved-pagination-does-not-allow-query-string-parameters/4348):
>
> Please don’t refer me to docs, it’s not there. Example from laravel public function indexAdmin() { if ($this-\>chklog() == 'notlogged') { return redirect('admin'); } $page = Request::input('page', '1'); //$rowsPerPage = 10; //$offset = ($page - 1) \* $rowsPerPage; $dogsearch = (isset($\_REQUEST['psch']) \<\> '' ? $\_REQUEST['psch'] : ""); $dogsch = $dogsearch . "%"; $aval = (isset($\_REQUEST['aval']) \<\> '' ? $\_REQUEST[…

---

<div class="post-metadata">

**Author:** ![e4hats](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@e4hats](https://discourse.cakephp.org/u/e4hats)\
**Post date:** [September 23, 2019, 3:20pm UTC](https://discourse.cakephp.org/t/paginate-condition/6635/3 "2019-09-23T15:20:06Z")

</div>

I have solved this issue by adding [‘OR’] into function resetConditions() as follows.

$conditions[‘OR’][] = array($this-\>name . ‘.sku LIKE’ =\> $st . ‘%’);

Thank you for your help!
