表未加入 Kohana 3.1 ORM
我该如何让它发挥作用?
$stuff = ORM::factory('mytable')
->with('user')
->with('other_stuff')
->find_all();
我已经设置了所有关系,当我执行其他查询时,一切似乎都正常。但是,在上面的查询中,它没有将表 users 连接到 mytable。我认为这可能是因为一个 mytable 可以有很多用户。
在参考文献中,有一种名为 join()
的方法,我想我可能需要在这里使用它,但他们没有提供任何相关信息,而且我在这里搜索的内容不起作用。
当我尝试使用 join
而不是 with
时,它会尝试加入表,但它不包含任何“加入”信息,只给出一个空的 ()
。
我知道我的 ORM DB 关系都设置正确,所以我有点困惑。
How do I get this to work?
$stuff = ORM::factory('mytable')
->with('user')
->with('other_stuff')
->find_all();
I've got all of my relationships set up and everything seems to be working when I do other queries. However, in the query above it is not joining table users to mytable. I think it may be because there can be many users for one mytable.
In the reference there is a method called join()
which I think I might need to use here, but they don't give any information on it, and the stuff I've searched for on here does not work.
When I try to use join
instead of with
, it tries to join the table, but it doesn't include any "join on" information, just gives an empty ()
.
I know my ORM DB relationships are all set up correctly, so I'm a bit baffled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Kohana 有不错的文档,没有在正确的位置查找......好吧,你的问题。
ORM::with()
用于加载一对一(属于并具有一个)关系,尽管您拥有所有 Database_Query_Builder 与 ORM 一起使用的方法可供您使用:Kohana has decent documentation, not looking in the right place is ... well, your problem.
ORM::with()
is used for loading one-to-one (belongs to and has one) relations, though you have all the Database_Query_Builder methods to use with ORM on your disposal:上面的查询是如何用kohana的ORM格式编写的?下面的一项是否正确
How the above query is written in ORM format of kohana? Is the below one is correct