我有一张桌子records
和另一张桌子categories
我想获取此类别中的所有记录
$all_categories = '5,6,7,8';
所以我正在使用这段代码:
$query = $this->Records->find('all',[
'contain' => ['Categories']
]);
if(!empty($search)){
$query->where(['Records.title LIKE' => '%'.$search.'%']);
}
if(!empty($wilaya)){
$query->where(['Records.adresse LIKE' => '%'.$wilaya.'%']);
}
if(!empty($cat)){
$query->where(['Records.category_id =' => $cat]);
} else {
$categories_array = explode(',',$all_categories);
foreach($categories_array as $category) {
$query->where(['Records.category_id =' => $category]);
}
}
当我使用它时,默认情况下我会得到AND
-conditions 。
我怎样才能得到OR
-conditions 呢?