原则2,不能排序
我无法对我的集合进行排序,我尝试按字段对关联的连接表进行排序。
$query = $this-em->createQueryBuilder()
->select('u')
->from('\Entities\Users', 'u')
->leftJoin('u.comments', 'c')
->orderBy('c.feat', 'ASC')
->addOrderBy('c.position', 'ASC')
->getQuery();
我对用户实体的注释包含用于连接评论表的注释:
/** @ManyToMany(targetEntity="\Entities\Comments", mappedBy="discoverycategories")*/
protected $comments
i cant sort my collection, i tried to sort the associated joined table by a field..
$query = $this-em->createQueryBuilder()
->select('u')
->from('\Entities\Users', 'u')
->leftJoin('u.comments', 'c')
->orderBy('c.feat', 'ASC')
->addOrderBy('c.position', 'ASC')
->getQuery();
my annotations for the users entities contains this for joining the comments table:
/** @ManyToMany(targetEntity="\Entities\Comments", mappedBy="discoverycategories")*/
protected $comments
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 orderBy 方法不接受第二个参数。但你必须这样说
I think that the orderBy method doesnt accept a second parameter. But you have to put it like this instead