学说中的有序多对多关系?
尝试使用 WebsiteCategory
作为 refClass 将 Categories
链接到 Websites
。
时应检索类别的顺序
WebsiteCategory
有一个 rank
列,它指示当您调用 $website->getCategories()
我愣住了,没想到这么难。有人可以帮忙吗?
Attempting to link Categories
to Websites
, using WebsiteCategory
as the refClass.
WebsiteCategory
has a column rank
, which indicates the order in which the categories should be retrieved when you call $website->getCategories()
I'm stumped, didn't think this would be so difficult. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无法获得理论来对关系进行本地排序(就像 Damien 所建议的那样),而是向模型添加了一个 getCategories() 函数,该函数运行正确的查询并返回结果集。
Was not able to get doctrine to order the relationship natively (like Damien was suggesting) instead, added a getCategories() function to the model which runs the proper query and returns the result set.
多对多关系不支持此功能,错误报告链接在下面,其中包含可能的补丁,尽管一些评论表明它不起作用。正如OP已经指出的,我认为解决方案是重写 getCategories() 函数。
http://www.doctrine-project.org/jira/browse/DC-651
This is not supported for Many to Many relationships, the bug report is linked below with a possible patch, although some comments indicate it was not working. As already noted by OP, I think the solution is to override the getCategories() function.
http://www.doctrine-project.org/jira/browse/DC-651
您可以在 schema.yml 中添加 orderBy 参数:
您可以使用逗号放置多个字段。
You can add an orderBy param in your schema.yml:
You can put multi fields with a comma.