Ordering Cactivedataprovider From Second Join

Hi

I have the following code:


	public function actionIndex($id) 

	{

		

		$dataProvider=new CActiveDataProvider('Item', array(

			'criteria' => array(

			'with' =>'Area',

			'condition' => 't.Area_id=:id',

			'params' => array(':id'=>$id),



What I need to do is join another table of featured Items and then order the whole thing with by what results are featured?

So far I got to this:


	public function actionIndex($id) 

	{

		

		$dataProvider=new CActiveDataProvider('Item', array(

			'criteria' => array(

			'with' =>'Area',

			'condition' => 't.Area_id=:id',

			'params' => array(':id'=>$id),

                        'with' =>'featuredItems',






But then I just keep inuring errors if I try to order the results. I’m not sure how to use the Item.id to join the featuredItems.item_id as a condition? Or if that column data would even be available during this point in the query

Use my RelatedSearchBehavior extension. It’s intended to be used in a ‘search()’ function but it does return a DataProvider’.

To respond to your question: the join is to be specified in the relations of the model class, where ‘with’ references this relation. This implies that the CCommandBuilder will include the relation in the query. As the relation is then included in the query, you can reference it in the sort.

Ah ok tahnk you.

I managed to get the join across ok, it was the params and condition I had trouble with.

Will look at the behaviours extension too.

Thanks very much