I have a scenario like this:
I have a user table for login.I have 2 types of users with 2 types type1 ,type2.
While creating type1 user,I am saving his personalinfo(name,surname etc) in a type1_info table, address in type1_address table.I have a table type1_transaction which has a different ids of tables user,type1_info,type1_address.
Now,I want a name of type1 user,from his id in user table.
Now,I have no direct relation between id in user table and type_info table,
I have to get id of type1_transaction table,& than from it I will be get id of type_info table.
For that,I have made following solution.
1)I have take a field of type1_transaction in type1_info.(type1_info_transaction_id)
2)I have make relation with type1_transaction
'rel_tran' => array(self::BELONGS_TO, 'Type1Transaction','', 'on' => 't.created_by=type1_user_id'),
here in created by,I have user table id.
type1_user_id is a field in transaction table which has value of user id.
3)I have make relation with type1_info
here type1_transaction_id is auto-increment id of type1_transaction table.
4)Declare type1_name as public variable & in search,
In search method
$criteria->with = array('rel_tran','rel_info'); $criteria->compare('rel_info.type1_name',$this->type1_name,true);
5)In gridview get value with $data->rel_info->type1_name.
This way,I got name with searching in gridview with 2 level dependancy.
I have write type1 as a understanding purpose,put your correct table name instead.
Hope,it may useful to other.
If any other better way to achieve this,than you can suggest me.