thinkphp 데이터 페이지 나누기

4057 단어 thinkphp
방법 1:
 
 1 public function show_cate(){

 2         

 3         $category_name = array(

 4             '1' => ' ',

 5             '2' => ' ',

 6             '3' => ' ',

 7             '4' => ' ',

 8             '5' => ' ',

 9             '6' => ' ',

10             '7' => ' ',

11             );

12         $category_id = I('get.category_id');

13         $model = M('zx_article');

14                                  // 

15         $count = $model->where('category_id ='.$category_id)->order('article_id desc')->count();

16                                 // Page , 

17         $page = new \Think\Page($count,2);

18                               // limit 

19         $data = $model->where('category_id ='.$category_id)->order('article_id desc')->limit($page->firstRow.','.$page->listRows)->select();

20                                 // 

21         $this->assign('data',$data);

22                                // Page show() 
23 $this->assign('page',$page->show()); 24 $this->assign('name',$category_name[$category_id]); 25 $this->display(); 26 }

좋은 웹페이지 즐겨찾기