Kohana ORM关系

时间:2011-08-10 08:04:14

标签: kohana kohana-orm

我有几张表并为他们定义了关系。

{Table Department} {Table Unit} {Table Branch}

一个部门可以有多个分支,一个分支只能属于一个部门。我需要能够获得部门名称,departmentid,branchname

Branch has an instance of departmentid in it.

如何在一次ORM通话中提取此内容?

class Model_Admin_Departments extends ORM

{

protected $_has_many = array('branches' => array ());


class Model_Admin_Branches extends ORM

{     protected $ _belongs_to = array('departments'=> array());

我还在db端创建了外键约束,并在delete上创建了动作级联。这会导致问题还是没问题?

1 个答案:

答案 0 :(得分:0)

假设您拥有正确的relationships declared,您应该可以在ORM对象上使用with(...) method