Cactivedataprovider Column Not Found


I’m a bit confused about the different behaviour between ::model() and CActiveDataProvider. Using the same criteria object:

$crit = new CDbCriteria();

$crit->with = array( 'categoryHasLanguages' );

$crit->select = array(


	new CDbExpression('IFNULL(categoryHasLanguages.translation, AS name'),



$crit->addColumnCondition( array(

	'id_organization' => $organization,

	'categoryHasLanguages.id_language' => $lang,

) );


Category::model()->findAll( $crit );

works, but calling

$dataProvider = new CActiveDataProvider( 'Category', array( 'criteria' => $crit, ) );

, doesn’t. I know how to get it working, adding

$crit->together = true;

, but I’m asking if someone can explain this to me :)

Hi kwyjibo, welcome to the forum.

I just wrote a wiki on this issue. Please take a look at this.

In addition, please note that usually ‘LIMIT’ is added implicitly to the criteria when you are working with CActiveDataProvider.

Wow, very clear explanation ;) Thank you!