CDbCriteria stopped functioning properly after last update

I just updated to the last version of yii and CDbCriteria seems to malfunction. For example, the following code:

                $criteria = new CDbCriteria ();

		$criteria->select = ',, count(distinct sl.subscriber) as dashboardTotalSubscribes';

		$criteria->distinct = true;

		$criteria->join = 'inner join subscriber_list sl on(';

		$criteria->condition = 'sl.status=:active and sl.date_added>:7days';

		$criteria->order = 'dashboardTotalSubscribes desc';

		$criteria->having = 'dashboardTotalSubscribes>0';

		$criteria->group = '';

		$criteria->limit = 10;


		$criteria->params = array ( 


			'active' => 'active', 

			'7days' => time () - ( DateHelper::day () * 7 ) 


		return new CActiveDataProvider ( 'Lists', array ( 


			'criteria' => $criteria 

		) );

produces the following query:

SELECT COUNT(DISTINCT FROM `list` `t` inner join subscriber_list sl on( WHERE sl.status=:active and sl.date_added>:7days GROUP BY HAVING dashboardTotalSubscribes>0

And the following error:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dashboardTotalSubscribes' in 'having clause'

Can anyone tell me why isn’t the query complete?

I’m also having the same issue,








            'order'=>'usersScrolls.modified ASC',




I would love some help understanding any of this.

I also think that something broke with latest patch…

Hi guys.

You are right, there is something broken since long, and since the last patch it trows an exception instead of returning a wrong result.

The staff is working on it, meanwhile you can use my workaround for going over.

Workaround: save the file in the next post in components and add this line to the db config:



Here are the bug signalation:


Here the file for workaround

Thanks Zaccaria,

I also found another post that talks about how CActiveRecord doesn’t deal with MANY:MANY relationships well and whenever adding a “limit” it breaks. The solution to that is to create a table view. I did that and it works great.