160

findBy()Doctrineリポジトリでこのメソッドを使用しています:

$entities = $repository->findBy(array('type'=> 'C12'));

結果を注文するにはどうすればよいですか?

4

3 に答える 3

334

の2番目のパラメータfindByはORDER用です。

$ens = $em->getRepository('AcmeBinBundle:Marks')
          ->findBy(
             array('type'=> 'C12'), 
             array('id' => 'ASC')
           );
于 2012-08-21T04:45:48.053 に答える
29
$ens = $em->getRepository('AcmeBinBundle:Marks')
              ->findBy(
                 array(), 
                 array('id' => 'ASC')
               );
于 2013-05-17T05:58:37.780 に答える
12
$cRepo = $em->getRepository('KaleLocationBundle:Country');

// Leave the first array blank
$countries = $cRepo->findBy(array(), array('name'=>'asc'));
于 2013-11-14T05:17:55.150 に答える