[英]pagination is not working with store procedure in yii
I wants to do pagination with Store Procedure yii, when i load page first time it shows me 10 records but when i click on 2nd page it shows me no record found, Here is my code 我想使用存储过程yii进行分页,当我第一次加载页面时,它显示10条记录,但是当我单击第二页时,它显示没有找到记录,这是我的代码
if(isset($_GET['page']) && $_GET['page']!='') {
$page = $_GET['page'];
} else {
$page = 1;
}
$SP = "CALL Dormantreport(1,'2015-01-01','2015-12-31','',".$page.",10)";
$command = Yii::app()->db->createCommand($SP);
$rawDataWithArray = $command->queryAll();
$filteredData=$filtersForm->filter($rawDataWithArray);
$model = new CArrayDataProvider($rawDataWithArray, array(
'keyField' => 'MemberID',
'totalItemCount' => 78, //count($rawDataWithArray),
'sort' => array(
'attributes' => array(
'MemberID',
),
'defaultOrder' => array(
'MemberID' => CSort::SORT_DESC,
),
),
'pagination' => array(
'pageSize' => $PageSize,
),
));
return $model;
Can anyone please tell me what i need to do now to solve this pagination issue, any help will be really appreciated, 谁能告诉我我现在需要解决此分页问题,我们将不胜感激,
In your model, 在您的模型中
public function search() {
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria;
$criteria->order = 'employeedetailsid DESC';
$criteria->compare('employeedetailsid', $this->employeedetailsid);
$criteria->compare('employeemasterid', $this->employeemasterid);
$criteria->compare('employeedetails_qualification', $this->employeedetails_qualification, true);
$criteria->compare('employeedetails_experience', $this->employeedetails_experience, true);
$criteria->compare('employeedetails_address1', $this->employeedetails_address1, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'pagination' => array(
'pagesize' => 25,
)
));
}
Try this.... 尝试这个....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.