使用带有PHPCR-ODM的 Document 类,可以使用类存储库获取结果,结果自动按sort_order
不在 Document 类中但在数据库模式中的字段排序。
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 类的字段。
那么,我怎样才能对我的结果进行排序呢?