<?php
namespace App\Repository;
use App\Entity\Celebrites;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Celebrites|null find($id, $lockMode = null, $lockVersion = null)
* @method Celebrites|null findOneBy(array $criteria, array $orderBy = null)
* @method Celebrites[] findAll()
* @method Celebrites[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CelebritesRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Celebrites::class);
}
public function getCelebriteRandom(Celebrites $celebrites, $limit)
{
return $this->createQueryBuilder('a')
->andWhere('a.id != :celebrite')
->setParameter('celebrite', $celebrites)
->orderBy('RAND()')
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
}