I want a basic syntax of relation and their parameters
i need these clarification
- Difference Between BELONGS_TO and HAS_ONE ?
- I want to use the relation on CGridView (That relation refers the another table element as a Foreign key ) For Eg I have Three tables
- Messenger
- UserLogin
- Userprofile
I am in Messenger Admin Grid I have Primary key of UserLogin table That userlogin have userprofile Primary key Now i want to access the userProfile fields in my grid
i already try the (through) in relation like
its in Messenger model
'relationeg'=>array(self::HAS_ONE,'Userprofile',array('user_id'=>'id'),'through'=>'user'),
'user'=>array(self::BELONGS_TO, 'UserLogin','user_id'),
i access this on my grid
.....
....
array(
'name'=>'message_by',
'value'=>'$data->relationeg->username'
),
....
...
But i got the wrong data's that are totally differ by the key of base table record
i have doubt on this line
'relationeg'=>array(self::HAS_ONE,'Userprofile',array('user_id'=>'id'),'through'=>'user'),
in this self::HAS_ONE means? when i add the where condition of the join query how will add the condition on this
Advance thanks
Your answer welcome