| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App\Repository;
- use App\Entity\Commentaire;
- use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
- use Doctrine\Common\Persistence\ManagerRegistry;
- /**
- * @method Commentaire|null find($id, $lockMode = null, $lockVersion = null)
- * @method Commentaire|null findOneBy(array $criteria, array $orderBy = null)
- * @method Commentaire[] findAll()
- * @method Commentaire[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class CommentaireRepository extends ServiceEntityRepository
- {
- public function __construct(ManagerRegistry $registry)
- {
- parent::__construct($registry, Commentaire::class);
- }
- public function findLast ($limit = 5)
- {
- return $qb = $this->createQueryBuilder('c')
- ->innerJoin('c.film', 'flm')->addSelect('flm')
- ->innerJoin('c.user', 'usr')->addSelect('usr')
- ->setMaxResults($limit)
- ->orderBy('c.id', 'DESC')
- ->getQuery()
- ->getResult();
- }
- }
|