我正在尝试使用具有复杂嵌套 AND 和 OR 条件的查询生成器来构建查询。这是我到目前为止所写的。
$cond_arr = array();
$cond_arr['VehicleBrandModels.status'] = 1;
$query = $this->VehicleBrandModels->find();
$query->hydrate(false);
$query->select($this->VehicleBrandModels);
$query->where($cond_arr);
$VBM_data = $query->toArray();
这将生成如下查询
SELECT * FROM vehicle_brand_models WHERE status = 1;
我想生成一个带有嵌套 AND & OR 条件的查询,如下所示
SELECT * FROM vehicle_brand_models WHERE status = 1 AND ((overall_rating > 0 AND overall_rating < 2) OR (overall_rating >= 2 AND overall_rating < 4) OR (overall_rating >= 4 AND overall_rating <= 5));
任何人都可以帮助解决如何在 CAKEPHP 3.0 查询生成器中实现这一目标吗?