Hi all,
On my scenario I have the following 2 tables (models) on Yii framework:
First table:
Person (id, name)
id name
1 Dan
2 Eva
3 Criss
4 Luis
5 Alex
6 Anna
7 Steve
8 Camy
9 WithoutChildren
10 WithoutParent
The second table is:
PersonParent (id, parent_id)
id parent_id
3 2
3 1
4 7
4 8
5 3
5 4
6 3
6 4
Person relations:
...
'parents' => array(
selft::MANY_MANY,
'Person',
'PersonParents(parent_id, id)'
),
'children' => array(
self::MANY_MANY,
'Person',
'PersonParents(id, parent_id)',
),
...
How can I define some functions/methods ( or relations?) on Person model to access them all over the framework, something like this:
-
hasParents(id)
-
hasChildren(id)
-
getChildren(id)
-
getParents(id)
-
getChildrenWithoutParents
-
getParentsWithoutChildren
Thanks!