When querying paging in a closure, the paging conditions for printing SQL are not attached. By default, all are displayed.
年年年年年
年年年年年 2019-03-06 11:43:58
0
5
1324

Why can the teacher write it directly and use it? When I tested it, everything was displayed. The paging conditions were ignored directly. When printing the sql, it showed that there were no paging conditions.

年年年年年
年年年年年

reply all(4)
尾生

Just change the position of that code:

public function index()
{
//Category information display
$cateId=Request::param('cate_id') : >assign('cateName',$res->name);
        $artList=Db::name('zh_article')
                                                                                                                                                     ;where('cate_id',$cateId)
                                                                                                                                                                                                                                                        through ',$artList);
}
else{
$artList=Db::name('zh_article')
->order('create_time','desc')->paginate(3);
$this->view->assign('cateName','All articles');
}
$this->view->assign('artList',$artList);

return $this->fetch();
}

尾生

抱歉,应该是这样的:

if (isset($cateId))
{
   $artList=Db::table('zh_article')
       ->where('status',1)
       ->where('cate_id',$cateId)
       ->order('create_time','desc')->paginate(3);



}
$artList=Db::table('zh_article')
   ->where('status',1)
   ->where('cate_id',$cateId)
   ->order('create_time','desc')->paginate(3);


$this->view->assign('artList',$artList);

    return $this->fetch();


尾生

if (isset($cateId))
{
   $artList=Db::table('zh_article')
       ->where('status',1)
       ->where('cate_id',$cateId)
       ->order('create_time','desc')->paginate(3);



}
$artList=Db::table('zh_article')
   ->where('status',1)

   ->order('create_time','desc')->paginate(3);


$this->view->assign('artList',$artList);

    return $this->fetch();

这样子可以出来

永~不~低~头

The same question

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!