根本没有效果 免费的课都是落后版本的课。。。学的这个闹心
不要用all方法,直接在外面写 类似这样: //列表信息的分类显示 $artList = Article::where('status', 1) ->where('cate_id', $cateId) ->order('create_time', 'desc') ->paginate(3);
有效果的,仔细看代码,把浏览器,以及系统缓存都清除掉
$cateId 不存在的情况下 $artlist = DB::table('zh_article') -> where('status',1)->order('create_time','desc')->paginate(3); 不需要 where ('cate_id' => $cateId)
1年前 添加回复 0
模型分页这样改就行了 if(isset($cateId)) { $artList = Article::where('status',1) ->where('cate_id',$cateId)->order('create_time','desc')->paginate(3); }else{ $art
3年前 添加回复 0
if (isset($cateId)){ $artList = Article::where('status',1) ->where('cate_id',$cateId) ->paginate(2); }else { $artList = Ar
4年前 添加回复 0
模型分页正解: $artlist = Article::where(function($query)use($cateid){ if(isset($cateid)){ $query->where("status",1) ->where("cate
4年前 添加回复 0
闭包里查询分页 打印sql 分页条件没有附加上 默认全部显示了
[最新 尾生 的回答] 那个代码换一下位置就可以了:public function index(){ //分类信息显示 $cateId=Request::param('cate_id'); //如果存在这个分类 if (isset($cateId)){ $res=ArtCate::get($cateId); $this->view->assign('cateName',$res->name); $artList=Db::name('zh_article') ->where('status',1) ->where('cate_id',$cateId) ->order('create_time','desc')->paginate(3); $this->view->assign('artList',$artList); } else{ $artList=Db::name('zh_article') ->where('status',1) ->order('create_time','desc')->paginate(3); $this->view->assign('cateName','全部文章'); } $this->view->assign('artList',$artList); return $this->fetch();}
时间:5年前
分页,用sql语句查询出来的data数组可以分页吗。$list=query($sql);好像不能用paginate()方法
[最新 的回答] 如果LZ想要将查询出来的数组分页的话将数组转JSON就可以了
时间:6年前
God_Like
模型分页正解 Article::where(“闭包函数”)->->paginate(3); 我是新手
4年前 添加回复 2