Strange Behavior With Clistview


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->mergeWith($criteria_procesos, 'AND');

$criteria->distinct = true;

$criteria->together = true;

$companias=new CActiveDataProvider('CompCompanias', array(







My view:

$this->widget('zii.widgets.CListView', array(



	'ajaxUpdate' => false,


I still can’t get it work, but I found that if I modify the resulting SQL query to group by ‘t0_c0’ (which is the id of the company), works. So my next question is, how can I disambiguate the ID field of companies so I can use it in $criteria->group?

Nevermind, I found in documentation that you need to use ‘t’ for the primary table, so the answer is to use ‘’.