Octobercms关系查询

时间:2018-11-20 17:27:07

标签: octobercms

  $res= product::with('categories','image')
  ->join('amjad_products_categories As pcs','amjad_products_.id','=','pcs.product_id')
   ->join('amjad_products_category AS pc','pcs.category_id','=','pc.id')
  ->where('pc.slug', 'Like', "'%".$this->param('slug')."%'")->get();
  echo '<pre>';
  print_r($res);

这段代码什么也没显示,但是当我运行原始查询时

select * from `amjad_products_` 
inner join `amjad_products_categories` as `pcs`
on `amjad_products_`.`id` = `pcs`.`product_id` 
inner join `amjad_products_category` as `pc`
on `pcs`.`category_id` = `pc`.`id` 
where `pc`.`slug` Like '%best-sellers%'

它显示4条记录,不知道十月厘米发生了什么事

0 个答案:

没有答案