I have the same Problem, i want to model a relationship between users so i can show later all Users who have a certain relation to the current User. So I need for my view an (Active)Dataprovider filled with Users who have the certain relationship to the certain user.
I tried different things but i am failing always, by joining on different attributes.
For now i have my Table User and a Table Relation. So this relationship is normally m:n, so by moddeling this i failed first.
My next step was, focussing on the Relation Table, so I tried to define 1:n relations between the relationclass and the Userclasses by doing:
Relationtable fields: (personfrom, personto, description)
public function relations(){
return array(
"knows" => array(self::HAS_ONE, 'Person', 'id'),
"isknown" => array(self::HAS_ONE, 'Person', 'id'
'on'=>'personfrom'), //sth like this would be nice to join id with personfrom here
);
}
So the Problem is, that the Relation always join Relation.personfrom with Person.id and i don’t know how to tell yii to use in the other case Relation.personto with Person.id.
I searched the whole day in the Forum and at the Documentary but i didn’t found anything usefull.
There is an interesting Option here called “on” but i dont know the Syntax. Im hoping that this is the keyword i’m searching for.
Another Opportunity is the join statement but i dont know the syntax here either.
So please help us, this is so important for my current Project.
Thank you