php - Records listed per page in Yii


I am a beginner in Yii. I am using the views/myModel/index.php page to list all records in the MySQL table. By default the number of records displayed per page is 10. How can I change it ?




First of all model folder should not contain index.php. this folder contains all classes related with your database tables(CActiveRecords) and other models.

for increasing number of records per page you can set pagesize of pagination in CGridView or CListView.

public function actionIndex()
    $dataProvider=new CActiveDataProvider('Invoice',
                'condition'=>'businessId='. Yii::app()->userInfo->business,





You can also do something like this in your code:

$criteria = new CDbCriteria;

$criteria->condition = "...";
$criteria->params = array();
$criteria->limit = 20;
$criteria->offset  = 0;
$records = YourModel::model()->findAll($criteria);  

Where limit is the number of records to show per page and offset is where the record number start, which you can use as your page number.

People are also looking for solutions to the problem: php - Is there any setting that indicate curl_multi_exec limits?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.