0
我對Kohana的ORM模型有疑問。我建立了一個基於2個支柱的用戶管理系統。Kohana ORM用戶和權利模型
起初角色......每個用戶都有不同的角色。 第二權利......每個角色都由不同的權利組成。
用戶和角色都是這樣工作的罰款:
class Model_Auth_User extends ORM {
protected $_has_many = array(
'roles' => array('model' => 'Role', 'through' => 'roles_users'),
);...}
class Model_Auth_Role extends ORM {
protected $_has_many = array(
'users' => array('model' => 'User','through' => 'roles_users'),
);...}
現在我想一些 - 瑞添加到這樣的角色:
class Model_Auth_Role extends ORM {
protected $_has_many = array(
'users' => array('model' => 'User','through' => 'roles_users'),
'rights' => array('model' => 'Right','through' => 'role_rights'),
);
和權限模型:
class Model_Auth_Right extends ORM {
protected $_has_many = array(
'roles' => array('model' => 'Role','through' => 'role_rights'),
);
如果我想訪問的角色,我只能使用這個:
$roles = $user->roles->find_all(); //works fine
現在我想獲得這個用戶/角色的所有權利: 當我試試這個:
$rights = $user->roles->rights->find_all();
我總是得到一個空的結果。 任何想法這裏有什麼不對? :)
在此先感謝
啊......非常感謝! – toffler