2019-04-22
2019-04-22 本文已影响0人
幻无虚生
$sub_order=$order_model->where($where)
->order('id desc')
->page($page,$limit)
->buildSql();
$goods_model=new goodsModel();
$order_list=$goods_model->alias('b')
->join([$sub_order=>'a'],'a.goods_id=b.goods_id')
->join('admin c','a.source_id=c.id','left')
->join('user d','a.openid=d.id','left')
->field('a.id,a.order_number,a.goods_name,a.order_amount,a.status,a.order_pay_time,a.status_decs,a.order_status,b.refund_amount,c.nick_name,d.nickname')
->order('order_pay_time decs')
->group('order_number')
->select();
使用了think的buildSql() 方法 先查询玩需要得数据 在进行关联查询 大大的减少了查询时间 有原来的十条数据需要10s 现在变成0.2秒