PagesRepository.php 610 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Entity\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. /**
  5. * PagesRepository
  6. *
  7. * This class was generated by the Doctrine ORM. Add your own custom
  8. * repository methods below.
  9. */
  10. class PagesRepository extends EntityRepository
  11. {
  12. public function getLatestPages($limit = null)
  13. {
  14. $qb = $this->createQueryBuilder('b')
  15. ->select('b')
  16. ->addOrderBy('b.created', 'DESC');
  17. return $qb;
  18. if (false === is_null($limit))
  19. $qb->setMaxResults($limit);
  20. return $qb->getQuery()
  21. ->getResult();
  22. }
  23. }