关联查询

$where = ['a.module_id' => $module_id, 'b.city_id' => $city_id];
if ($title) {
$where['b.name like ?'] = '%' . $title . '%';
}
$model = GoodsModel::notorm()
->alias('a')
->leftJoin('cate', 'b', 'a.cate_id = b.id')
->where($where);
$count = $model->count('a.id');
$list = $model
->page($page, $page_size)
->select('a.id,b.name')
->order('a.sort DESC,a.id DESC')
->fetchAll();

 

posted @ 2021-07-22 15:56  CanyingV  阅读(55)  评论(0编辑  收藏  举报