Doctrine orm 第2条原则-实体报告的排序方法?
有没有一种方法可以使用特定的条件对Doctrine 2Doctrine orm 第2条原则-实体报告的排序方法?,doctrine-orm,Doctrine Orm,有没有一种方法可以使用特定的条件对Doctrine 2EntityRepository对象进行排序,或者如果我想传递特定的排序参数,我是否必须使用DQL查询?您可以通过将第二个参数传递到find\uuuuuuuu方法来返回一组有序的元素,此参数必须是关联数组,其中键是要排序的字段的名称,值为“ASC”或“DESC” // query for one product matching be name and price $product = $repository->findOneBy(ar
EntityRepository
对象进行排序,或者如果我想传递特定的排序参数,我是否必须使用DQL查询?您可以通过将第二个参数传递到find\uuuuuuuu方法来返回一组有序的元素,此参数必须是关联数组,其中键是要排序的字段的名称,值为“ASC”或“DESC”
// query for one product matching be name and price
$product = $repository->findOneBy(array('name' => 'foo', 'price' => 19.99));
// query for all products matching the name, ordered by price
$product = $repository->findBy(
array('name' => 'foo'),
array('price' => 'ASC')
);
当然,如果您想要一个最复杂的行为,您应该实现一个自定义存储库。谢谢,这正是我想要的!