首頁  >  問答  >  主體

閉包裡查詢分頁 列印sql 分頁條件沒有附加上 預設全部顯示了

為什麼老師直接寫可以使用,我測試就全部顯示了,分頁條件直接無視了,打印sql顯示沒有分頁條件

年年年年年年年年年年2054 天前1329

全部回覆(5)我來回復

  • 尾生

    尾生2019-03-29 09:17:46

    那個程式碼換一下位置就可以了:

    public function index()
    {
       //分類資訊顯示
               $cateId=Request::param('cate_id') ;

               //如果有這個分類
       if (isset($cateId)){
           $res=ArtCate::get($cateId); >assign('cateName',$res->name);
           $artList=Db::name('zh_article')
               ->where('stat) 1) ;where('cate_id',$cateId)
               ->order('create_time','desc')->paginate(3);
        1 List$$this->-List> ',$artList);
       }
       else{
    #        $artList=Db::name('zh_article')
              -> ->order('create_time','desc')->paginate(3);
           $this->view->assign('cateName','全部文章');
       }
       $this->view->assign('artList',$artList);

            return $this->fetch();
    #}

    回覆
    0
  • 尾生

    尾生2019-03-27 22:46:52

    抱歉,應該是這樣的:

    if (isset($cateId))
    #{
         $artList=Db::table('zh_article')
          ->where_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();#######

    回覆
    0
  • 尾生

    尾生2019-03-27 22:44:21

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



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

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

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

        return $this->fetch();

    這樣子可以出來

    回覆
    0
  • 永~不~低~头

    永~不~低~头2019-03-24 14:22:37

    同問

    回覆
    0
  • 取消回覆