YII implements paging, YII implements paging _ PHP Tutorial

Source: Internet
Author: User
Tags php foreach
YII implements paging, and YII implements paging. YII implements paging. YII implements paging. This article describes how yii implements paging based on the instance code for your reference. the code is as follows: 1. part of the controller code: YII implements paging, and YII implements paging.

This article describes how to implement paging in yii by using the instance code for your reference. the specific code is as follows:

1. Some controller code:

public function actionTest() { $criteria=new CDbCriteria; $criteria->order='id DESC'; $count=User::model()->count($criteria); $pager=new CPagination($count); $pager->pageSize=10; $pager->applyLimit($criteria); $userList=User::model()->findAll($criteria); $this->render('test',array('list'=>$userList,'pages'=>$pager)); } 

2. View code:

<? Php foreach ($ list as $ o) {echo $ o-> username .'
'; Echo $ o-> id .'
';} $ This-> widget ('clinkpager', array ('header' => '', 'firstpagelabel '=> 'homepage ', 'lastpagelabel '=> 'Last page', 'prevpagelabel' => 'previous page', 'nextpagelabel '=> 'next page', 'page' => $ pages, 'maxbuttoncount' => 13);?>


Yii paging problem, urgent

SQL uses limit and offset. Use $ pages = new CPagination () for paging ();

How to implement three public methods in YII

You can first take a look at the basic tutorial and try to use the AR model. in this way, you can first create a posts table to store the public part of the published information, so that all resources can be in a basic model, you can use gii to generate the model and all the code of CURD, and then set a resource type based on posts, and associate the id with different resource tables. As for the tag, you can set another table, associate with the previous one.

In the example code, this article describes how to implement paging in yii for your reference. the specific code is as follows: 1. Some controller code :...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.