关于tp5的分页

浏览:2196 发布日期:2017/05/03 分类:ThinkPHP5专区 关键字: 分页
tp3.2分页,可以自己重组加入想要的字段然后再分页。tp5却不行,求怎么实现!!

3.2
$get = I("");
$User = M("course")->where(array("class"=>$get["class_id"]))->order('id desc')->select();
foreach ($User as $key => $value) {
$admin = M("admin")->where(array("id"=>$value["admin_id"]))->find();
$User[$key]["admin_name"] = $admin["username"];
}
$count = count($User);
$Page = new \Think\Page($count,16);
$show = $Page->show();// 分页显示输出
$list = array_slice($User, $Page->firstRow, $Page->listRows, true); //0,5
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出

5.0
$course_pay = db("course_pay")->paginate(8);
dump($course_pay->items());die();
$course = $course_pay->items();
foreach ($course as $key => $value) {
$order_pay = db("order_pay")->where(array("syllabus_id"=>$value["id"],"user_id"=>session("z_userid"),"is_pay"=>"1"))->find();
if($order_pay){
$course[$key]["url"] = "/Index/Course/payvediolist/vedio_id/".$course_pay[$key]["id"];
}else{
$course[$key]["url"] = "/Index/Course/pay/vedio_id/".$course_pay[$key]["id"];
}
$admin = db("admin")->where(array("id"=>$value["admin_id"]))->find();
$course[$key]["admin_name"] = $admin["username"];
}
$page = $course_pay->render();
$this->assign('list',$course_pay);// 赋值数据集
$this->assign('page',$page);// 赋值分页输出
return $this->fetch();
最佳答案
评论( 相关
后面还有条评论,点击查看>>