Kohana ORM 一对多反向查找
Kohana ORM 是否有反向关系查找。
例如:
模型 User
有 user_id, name
模型 Post
有 post_id, post, user_id
我有一个 user
对象并希望获取所有相关的 Posts
谢谢,希望这是有道理的
Does Kohana ORM have a reverse relationship lookup.
For example:
Model User
has user_id, name
Model Post
has post_id, post, user_id
I have a user
object and want to get all related Posts
Thanks, hope that makes sense
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答 - 是的,你可以做到。
对于关系属于(
post
)-有很多(用户
),您可以从帖子:或来自用户的帖子:
A short answer - yes you can do it.
For a relation belongs to (
post
) - has many (user
) you can load either the user from the post:or the posts from the user:
这是ORM 关系的文档。我希望这会对您有所帮助。
Here is the documentation of ORM relationships. I hope this will help you.