createQueryBuilder('a') ->andWhere('a.exampleField = :val') ->setParameter('val', $value) ->orderBy('a.id', 'ASC') ->setMaxResults(10) ->getQuery() ->getResult() ; } */ /* public function findOneBySomeField($value): ?AGridCol { return $this->createQueryBuilder('a') ->andWhere('a.exampleField = :val') ->setParameter('val', $value) ->getQuery() ->getOneOrNullResult() ; } */ public function findLastLicenceWithRef(){ // Check if has a customer $query = $this->_em->createQuery('SELECT 1 FROM App\Entity\Licence l WHERE l.ref IS NOT NULL '); $licence = $query->execute(); // if customer exist we recuperate last added if (!empty($customer)){ try { return $this->_em->createQuery('SELECT l FROM App\Entity\Licence l WHERE l.ref IS NOT NULL ORDER BY l.id DESC') ->setMaxResults(1)->getOneOrNullResult(); } catch (NonUniqueResultException $e) { } } return null; } }