thinkphp分页处理


sql 语句
$model = new Model();
$sqlcount = "select count(*) as cnt,a1.type as comtype,a1.content as comcontent,a1.id as comid from tp_appoint_order a2, (select * from tp_appoint_comment where token = '$token' )as a1,tp_appoint_technician as a3,tp_appoint_product as a4 where
a2.token = '$token' and a2.orderid = a1.orderid and a3.id = a1.technicianid and a2.projectid = a4.id
";
$count = $model->query($sqlcount);
$count = $count[0]['cnt'];
$Page = new Page ( $count, 20 );
$show = $Page->show ();
$sql = "select * ,a1.type as comtype,a1.content as comcontent,a1.id as comid from tp_appoint_order a2, (select * from tp_appoint_comment where token = '$token' )as a1,tp_appoint_technician as a3,tp_appoint_product as a4 where
a2.token = '$token' and a2.orderid = a1.orderid and a3.id = a1.technicianid and a2.projectid = a4.id
limit $Page->firstRow ,$Page->listRows

";
$data = $model->query($sql);
$this->assign ( 'page', $show );

tp 方法
$count=$techinician_model->where("token='$token'")->count();
$Page = new Page ( $count, 20 );
$show = $Page->show ();
$tech=$techinician_model->where("token='$token'")->limit($Page->firstRow . ',' . $Page->listRows)->select();
$this->assign('list',$tech);
$this->assign ( 'page', $show );

ajax分页
$currpage = $_POST['currpage'];//当前页码。 针对微店首页
$pagesize = $_POST['pagesize'];//当前页数据大小 针对微店首页
$products = $model->where($where)->order($orderstr)->limit(($currpage - 1) * $pagesize, $pagesize)->select();

声明:祁志飞||小祁的博客|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - thinkphp分页处理


QQ:137867590