在Kohana ORM中将具有两个不同外键的表引用到同一个表

在Kohana ORM中将具有两个不同外键的表引用到同一个表,orm,kohana,database-relations,Orm,Kohana,Database Relations,如您所见,同一个表中有两个外部字段。但是Kohana ORM default查找名为priority_id的字段,该字段不存在 有没有办法让Kohana ORM知道这两个字段是该表的外键。您可以使用文档中的“别名”@ 因此,在您的情况下,您的用户模型将是: table user: |id|name|employee_priority_id|user_priority_id| table priority: |id|name| 顺便说一句,根据Kohana的约定,表名应该是复数形式,除非您覆盖$

如您所见,同一个表中有两个外部字段。但是Kohana ORM default查找名为priority_id的字段,该字段不存在


有没有办法让Kohana ORM知道这两个字段是该表的外键。

您可以使用文档中的“别名”@

因此,在您的情况下,您的用户模型将是:

table user:
|id|name|employee_priority_id|user_priority_id|
table priority:
|id|name|
顺便说一句,根据Kohana的约定,表名应该是复数形式,除非您覆盖$table_名称,例如:

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