title: CakePHP 3 query combining IF/AND/OR
body: <p>How can I implement this code in CakePHP 3?</p>
  
  <pre><code>function notEmpty($field) {
      return isset($field) &amp;&amp; $field != '';
  }
  
  $conditions[] = notEmpty($group_id) ? "group_id LIKE %$group_id%" : '';
  $conditions[] = notEmpty($token) ? "firstname LIKE %$token% OR lastname LIKE %$token% OR username LIKE %$token%" : '';
  $conditions[] = notEmpty($parent_id) ? "parent_id LIKE %$parent_id%" : '';
  $conditions[] = notEmpty($status) ? "status1 LIKE %$status% AND status2 LIKE %$status%" : '';
  
  $conditions = array_filter($conditions , function($value) { return $value !== ''; });//Remove empty conditions
  array_walk($conditions, function(&amp;$item) { $item = "($item)"; });//Add () to conditions
  $where = !empty($conditions) ? 'WHERE '.implode(' AND ', $conditions) : '';
  $query = 'SELECT * FROM users '.$where;
  </code></pre>
  
  <p>I'm using pagination.</p>