[英]How to order results with findBy() in Doctrine
I am using the findBy()
method on a Doctrine repository: 我在Doctrine存储库上使用
findBy()
方法:
$entities = $repository->findBy(array('type'=> 'C12'));
How can I order the results? 我该如何订购结果?
The second parameter of findBy
is for ORDER. findBy
的第二个参数是ORDER。
$ens = $em->getRepository('AcmeBinBundle:Marks')
->findBy(
array('type'=> 'C12'),
array('id' => 'ASC')
);
$ens = $em->getRepository('AcmeBinBundle:Marks')
->findBy(
array(),
array('id' => 'ASC')
);
$cRepo = $em->getRepository('KaleLocationBundle:Country');
// Leave the first array blank
$countries = $cRepo->findBy(array(), array('name'=>'asc'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.