multi model relation multi model relation
Posted 12 April 2012 - 12:46 PM
From projects model how can I display name in user table.
yii establishes a relation between manager and projects
'managers' => array(self::BELONGS_TO, 'manager', 'manager_id'),
so in the view I can display managers.user_id.
but I can I establish a relation between projects to managers and then to manager to user and get the name of the user
in projects table
For example for every manager_id in projects table I want look the user_id for that manager in manager table and then find the user name in User table?
Any help is appreciated. Thanks.
Posted 12 April 2012 - 02:33 PM
However, I'd change your DB structure.
A manager is not a separate entity, just an attribute of a user. For example:
manager_id #fk on self
Posted 12 April 2012 - 06:57 PM
as far as i know, changing into innodb you will get relation automatically created through gii