thinkphp多表关联并且分页

时间:2022-10-27 14:26:03
$db_prefix = C('DB_PREFIX');
$Model = new Model();

 $data = $Model->table("{$db_prefix}ordernum as ou")->join("{$db_prefix}orderinfo as oi on  ou.ofid=oi.id")->join("{$db_prefix}weekprice as wk  on oi.wkid=wk.id")->join("{$db_prefix}stadiums as stm on wk.stm_id=stm.id")->join("{$db_prefix}sports as sp on wk.sp_id=sp.id")->field('ou.uid,oi.id,oi.ordernum,oi.total_money,oi.order_date,oi.ostat,oi.other,stm.stm_name,stm.stm_addr,stm.stm_unique,stm.id as stmid,sp.sp_name,sp.remarks')->where("ou.uid={$_SESSION['uid']}")->group("oi.ordernum")->order("oi.order_date desc")->limit($Page->firstRow . ',' . $Page->listRows)->select();