我想用Store Procedure yii进行分页,当我第一次加载页面时它显示了10条记录但是当我点击第2页时它显示我没有找到记录,这是我的代码
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;
任何人都可以告诉我现在需要做些什么来解决这个分页问题,任何帮助都会非常感激,
答案 0 :(得分:0)
在你的模特中,
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,
)
));
}
试试这个......