Hello,
I’ve noticed a strange behavior with clistview or maybe my code is wrong. When I try to get distinct id’s from a query, the count from the summary text it’s right but not in the actual results.
For example I made a query where I should get 9 elements; in summary text shows 9 elements but displays 10 elements (I get 1 duplicated element). It’s strange that the summary text gets the query right, but is displaying 1 duplicated element.
Any type of help would be appreciated, thanks.
My controller:
$criteria = new CDbCriteria();
$criteria_procesos = new CDbCriteria();
$procesos_arr = unserialize(urldecode($pquery)); //this is just an array of id's
$criteria_procesos->with = array('procesos'=>array(
'joinType'=>'INNER JOIN',
));
foreach ($procesos_arr as $elemento) {
$criteria_procesos->addCondition('procesos.id='.$elemento,'OR');
}
$criteria->mergeWith($criteria_procesos, 'AND');
$criteria->distinct = true;
$criteria->together = true;
$companias=new CActiveDataProvider('CompCompanias', array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>4,
'pageVar'=>'page'
),
));
My view:
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$companias,
'itemView'=>'_compania',
'ajaxUpdate' => false,
));