2009-08-28 3 views
1
table user: 
|id|name|employee_priority_id|user_priority_id| 
table priority: 
|id|name| 

같은 테이블에 두 개의 외부 필드가 있습니다. 그러나 Kohana ORM 기본값은 존재하지 않는 priority_id라는 필드를 찾습니다.Kohana의 동일한 테이블에 두 개의 다른 외래 키가있는 테이블 참조 ORM

Kohana ORM이 두 필드가 해당 테이블의 외래 키임을 알 수있는 방법이 있습니까? 귀하의 경우 그래서 http://docs.kohanaphp.com/libraries/orm/advanced#aliasingenhancing_the_meaning_of_your_relationships

@ 설명하는대로 당신은 '앨리어스'를 사용할 수 있습니다

답변

2

, 당신의 User_Model은 다음과 같습니다 BTW

class User_Model extends ORM { 
    protected $belongs_to = array('employee_priority' => 'priority', 'user_priority' => 'priority'); 
} 

, Kohana의 규칙 테이블 이름에 따라 복수 형태 않는로되어야한다 예를 들어 $ table_name을 덮어 씁니다. 예 :

class Priority_Model extends ORM { 
    protected $table_name = 'priority'; 
}