How to put SQL-Query in DBCriteria for CActiveDataProvider

Hey guys,

I have the following SQL-Select-Statement I want to use, to populate my CActiveDataProvider.




	SELECT tb_comment.* FROM tb_user, tb_image, tb_comment 

	WHERE 

	tb_user.idUser=1 AND 

	tb_user.idUser=tb_image.idUser AND 

	tb_image.idImage = tb_comment.idImage AND

	tb_comment.idWriter != 1



How do I put the Query in a CDbCriteria or is there a better solution?

http://www.yiiframework.com/doc/api/1.1/CSqlDataProvider/ ?

Yeah that is what I was looking for…

Unfortunatly I get the error:


Undefined index: id


/var/www/yii/framework/web/CSqlDataProvider.php(116)

Here is the CSqlDataProvider:




			$recentCommentDataProvider = new CSqlDataProvider($sql, array(

			    'totalItemCount'=>$count,

			    'sort'=>array(

				'attributes'=>array(

				     'dateCreated',

				),

			    ),

			    'pagination'=>array(

				'pageSize'=>10,

			    ),

			));