How to sort findAll Doctrine's method?

前端 未结 12 2126
闹比i
闹比i 2020-12-23 00:14

I\'ve been reading Doctrine\'s documentation, but I haven\'t been able to find a way to sort findAll() Results.

I\'m using symfony2 + doctrine, this is the statemen

12条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 00:52

    It's useful to look at source code sometimes.

    For example findAll implementation is very simple (vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php):

    public function findAll()
    {
        return $this->findBy(array());
    }
    

    So we look at findBy and find what we need (orderBy)

    public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    

提交回复
热议问题