tp3.2原生态关联表调取数据

                $currentPage = I('request.pageNum',1);
$numPerPage = I('request.PageSize',30);
$begin = ($currentPage-1)*$numPerPage;
$model = new \Think\Model();
$sql = "select * from yc_order a left join yc_order_detail b on a.orderid = b.order_id where a.paidstatus=1 and b.farm_id=".$farmid;
$count = $model->query($sql);
$this->totalCount = count($count);
$this->data = $model->query($sql." limit $begin,$numPerPage");

你可能感兴趣的:(thinkphp笔记)