Answer the question
In order to leave comments, you need to log in
How to make CPagination fetch correctly?
Hello. There are 4 records in the database, 3 of them have parameters that must satisfy the selection and be displayed on the page in the pagination.
While for an example I deduce on one record.
$criteria = new CDbCriteria();
$total = UserDonate::model()->count();
$pages = new CPagination($total);
$pages->pageSize = 1;
$pages->applyLimit($criteria);
$userDonate = Yii::app()->db->createCommand()
->select('name,lastname,donate,inhonor,date,country_code,country_name_ua')
->from('{{user}} user')
->join('{{user_donate}} ud', 'user.id=ud.user_id')
->join('{{countries}} country', 'user.country=country.id')
->limit($pages->pageSize, $pages->currentPage)
->where(array('and', 'ud.status=1', 'ud.prog_id=:prog_id'), array(':prog_id'=>$prog_id))
->queryAll();
->where(array('and', 'ud.status=1', 'ud.prog_id=:prog_id'), array(':prog_id'=>$prog_id))
Answer the question
In order to leave comments, you need to log in
Why not via www.yiiframework.com/doc/api/1.1/CActiveDataProvider ?
$dataProvider = CActiveDataProvider(
'user',
array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>1,
//'pageVar' =>'page',
),
)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question