Access Model Attribute With Two Relation.

I have a problem while sorting model attribute that we are displaying with two relations.

$sort = new CSort;

            $sort->attributes = array(

‘c_name’=>array(

                            'asc' => 'client.name',


                            'desc' => 'client.name DESC'


                            ),  


             ),'*',


            );





            return new CActiveDataProvider($this, array(


                    'criteria'=>$criteria,


                    'sort'=>$sort,


            ));

this works fine it has only one relation client.

but when i have two relation,

‘project_name’=>array(

                            'asc' => 'Subscription.project.p_name',


                            'desc' => 'Subscription.project.p_name DESC'


                            ),'*',

where Subscription and project are relations.How can i do this one??

Here i have one model StudentTransaction in it this code is define, and i want to get cityname throught it in desc order.

here in this model Rel_Student_Address(relation) is define which refer to StudentAddress Model

then in my StudentAddress Model Rel_c_city(relation) is defines which refer City Model

may this following code which is work for me can help you to solve your problem




$stud_data = new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

			'sort'=>array(

			'attributes'=>array(

           		        'student_transaction_student_address_id'=>array(    

              		        'desc'=>'Rel_Student_Address.Rel_c_city.city_name DESC',

			       ),

           		 ),

		      ),

		));






http://www.yiiframework.com/extension/relatedsearchbehavior/ !!!