How to order results with findBy() in Doctrine

前端 未结 3 606
野性不改
野性不改 2021-01-30 07:31

I am using the findBy() method on a Doctrine repository:

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

How can

相关标签:
3条回答
  • 2021-01-30 08:15
    $cRepo = $em->getRepository('KaleLocationBundle:Country');
    
    // Leave the first array blank
    $countries = $cRepo->findBy(array(), array('name'=>'asc'));
    
    0 讨论(0)
  • 2021-01-30 08:24

    The second parameter of findBy is for ORDER.

    $ens = $em->getRepository('AcmeBinBundle:Marks')
              ->findBy(
                 array('type'=> 'C12'), 
                 array('id' => 'ASC')
               );
    
    0 讨论(0)
  • 2021-01-30 08:31
    $ens = $em->getRepository('AcmeBinBundle:Marks')
                  ->findBy(
                     array(), 
                     array('id' => 'ASC')
                   );
    
    0 讨论(0)
提交回复
热议问题