0
votes

I have a couple of tables and have defined relationships for them.

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

A Department can have more than one branch, a branch can only belong to one department. I need to be able to get the department name, departmentid, branchname

Branch has an instance of departmentid in it.

How do I pull this in one ORM call?

class Model_Admin_Departments extends ORM

{

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


class Model_Admin_Branches extends ORM

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

I have also created the foreign key constraints on the db side with action cascade on delete. Could this cause problems or that is fine?

1

1 Answers

0
votes

Assuming you have the right relationships declared you should be able to use the with(...) method on your ORM object.