php 如何在 Doctrine 中使用 findBy() 对结果进行排序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12048452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:42:33 来源:igfitidea点击:
How to order results with findBy() in Doctrine
提问by Mirage
I am using the findBy()method on a Doctrine repository:
我findBy()在 Doctrine 存储库上使用该方法:
$entities = $repository->findBy(array('type'=> 'C12'));
How can I order the results?
如何对结果进行排序?
回答by xdazz
The second parameter of findByis for ORDER.
的第二个参数findBy用于 ORDER。
$ens = $em->getRepository('AcmeBinBundle:Marks')
->findBy(
array('type'=> 'C12'),
array('id' => 'ASC')
);
回答by Jethik
$ens = $em->getRepository('AcmeBinBundle:Marks')
->findBy(
array(),
array('id' => 'ASC')
);
回答by Bhaktaraz
$cRepo = $em->getRepository('KaleLocationBundle:Country');
// Leave the first array blank
$countries = $cRepo->findBy(array(), array('name'=>'asc'));

