当前位置: 代码迷 >> 综合 >> 07thinkphp TP mysql join使用
  详细解决方案

07thinkphp TP mysql join使用

热度:40   发布时间:2023-10-10 23:33:00.0
public function lst(Request $request,int $cid){// dump($cid);// 根据cid查tb_spu表,cid3字段 = $cid// 需要执行的sql语句如下#  select * from tb_spu as p join tb_sku as k on p.id = k.spu_id limit 10;$spus = Db::table('tb_spu')->alias('p')->where('cid3',$cid)->join('tb_sku k','p.id = k.spu_id')->paginate(10); //返回一个对象类型// $page = $spus->render();#将一个tp查询结果集collection对象转换为数组// dump($spus->toArray());return view('lst',['spus'=>$spus]);}

 

  相关解决方案