I have a model which have query with join in CDbCriteria like this
public function cpu($filter)
{
$criteria = new CDbCriteria;
$criteria->alias = 'op';
$criteria->select = "op.*, oc.trainingtype_c";
$criteria->join = 'join opportunities_cstm oc on op.id=oc.id_c ';
$criteria->join .= 'join users u on op.assigned_user_id=u.id ';
$criteria->condition = "u.deleted=0 and op.deleted=0 and not op.assigned_user_id is null ";
$criteria->order = 'op.assigned_user_id, oc.expectdate_c';
if ($filter['department']!='Nasional') {
if ($filter['department']=='DKI (All)')
$criteria->condition .= "and u.department like 'DKI%'";
else if ($filter['department']=='NDD (All)')
$criteria->condition .= "and u.department like 'NDD%'";
else
$criteria->condition .= "and u.department like '".$filter['department']."'";
}
if ($filter['training_type']!='Semua') {
$criteria->condition .= "and oc.trainingtype_c like '".$filter['training_type']."'";
}
if ($filter['account_name']!='') {
$criteria->condition .= "and op.id in ( select opportunity_id
from accounts t1 join accounts_opportunities t2 on t1.id=t2.account_id
where t1.name like '%".trim($filter['account_name'])."%' )";
}
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
),
));
}
and a view to render it like this,
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'cpu-grid',
'dataProvider'=>$model->cpu($filter),
'filter'=>$model,
'columns'=>$column,
));
it’s working fin for first page, but gives empty data for second and other pages.
did I miss something?
regards,
NH