Kohana ORM 关系
我有几个表并为它们定义了关系。
{Table Department} {Table Unit} {Table Branch}
一个部门可以有多个分支机构,一个分支机构只能属于一个部门。我需要能够获取部门名称、部门 ID、分支名称
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('部门' => array());
我还在数据库端创建了外键约束,并在删除时使用级联操作。这会导致问题吗?还是没关系?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您拥有正确的声明的关系,您应该能够使用
with(...)
方法。Assuming you have the right relationships declared you should be able to use the
with(...)
method on your ORM object.