在学说中订购了许多关系?

时间:2011-07-20 23:30:08

标签: sorting symfony1 doctrine many-to-many

尝试使用Categories作为refClass将WebsitesWebsiteCategory相关联。

WebsiteCategory有一列rank,表示在您致电$website->getCategories()

时应检索类别的顺序

我很难过,没想到会这么难。有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

无法让学说本地订购关系(就像Damien所建议的那样),而是将getCategories()函数添加到运行正确查询并返回结果集的模型中。

答案 1 :(得分:1)

多对多关系不支持这种情况,下面将错误报告与可能的补丁相关联,尽管有些评论表明它无效。正如OP已经指出的那样,我认为解决方案是覆盖getCategories()函数。

http://www.doctrine-project.org/jira/browse/DC-651

答案 2 :(得分:0)

您可以在schema.yml中添加orderBy参数:

Gallery:
  columns:
    title: string(255)
  relations:
    Images:
      local: id
      foreign: gallery_id
      foreignAlias: Gallery
      type: many
      orderBy: position DESC

您可以使用逗号添加多个字段。

相关问题