one to many relation with only one table ?


is it possible with AR to have a one to Many relation with only one table

where the one to many relation would be based on a parentid ?

ex: meetings table where a meeting could be made of many sub meetings

all meetings have same attribute so no need for a different table

we could also imagine an event table, where they could be linked together

can this be described in the models relation method ?

ofcourse it can… it has nothing to do with AR but only with your database design.

E.g. - employee (can also be a manager)






manager_id is the foreign key which refers to a primary key ‘id’ in the same table.

so the relation in the model Employee will be

'manager' => array(self::BELONGS_TO, 'Employee', 'manager_id');