【发布时间】:2017-12-19 11:44:11
【问题描述】:
使用带有PHPCR-ODM 的Document 类,可以使用fetch results with the class repository,结果将自动按不在Document 类中而是在数据库模式中的字段sort_order 排序。
在 Symfony Profiler 中记录的查询示例:
SELECT path FROM phpcr_nodes WHERE parent = ? AND workspace_name = ? ORDER BY sort_order ASC
我用 queryBuilder 构建了这个简单的查询:
$qb->from()
->document('AppBundle\Document\Product', 'product')
->end()
->where()
->neq()->field('product.type')->literal('category');
$query = $qb->getQuery();
结果不像其他查询那样按字段sort_order排序,我不能使用orderBy方法,因为这不是Document类的字段。
那么,如何对结果进行排序?
【问题讨论】:
-
还是一头雾水,再读一遍“结果自动按不在 Document 类中的字段
sort_order排序”然后再读“结果不像其他查询那样按字段sort_order排序” ",您是否希望您的查询按sort_order列排序?另一方面,我不知道其余查询是如何按sort_order“自动”排序的,因为 AFAIK 这不可能,也许我错了
标签: php doctrine-orm doctrine-odm doctrine-phpcr