with condition in findall() or DataProvider

I am trying to build a dataprovider for a grid view. I have tried to use CActiveDataProvider, but I cant find a way to use a ‘with’ in the condition. In another forum i found the following solution.

$quotes = someModel::Model()->with(‘projectR’)->findall(array(‘condition’=>‘quoteId = ‘.$findQ.’ OR name LIKE %’.$findQ.’% AND projectR->owner=’.$user.’’,‘pagination’=>false));

basically with this, i am passing a project list. but i only want to pass projects that belong to the owner of the project. Is there a better way using CActiveDataProvider? or is the above solution close to what i should be doing? Thanks in advance for any help.

Look at this example:


Next, I’ll show you a piece of code that I wrote in the past for one of my projects, in which I use a with:


	public function search()


		$criteria=new CDbCriteria;


		$criteria->with = array('category'=>array('alias'=>'c'), 'user'=>array('alias'=>'u'));



		$criteria->compare('c.name', $this->category_id,true);



		$criteria->compare('u.username',$this->user_id, true);


		return new CActiveDataProvider('Post', array(



				'defaultOrder'=>'p.id DESC, p.language ASC',



				'pageSize'=>Parameter::getValue(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' />,




Thank you! This was exactly what i was looking for. You got me on the right track, and it works great.