You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.9 KiB
70 lines
1.9 KiB
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Pokemon;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @method Pokemon|null find($id, $lockMode = null, $lockVersion = null)
|
|
* @method Pokemon|null findOneBy(array $criteria, array $orderBy = null)
|
|
* @method Pokemon[] findAll()
|
|
* @method Pokemon[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
*/
|
|
class PokemonRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Pokemon::class);
|
|
}
|
|
|
|
/**
|
|
* @param $params
|
|
* @return Pokemon[] Returns an array of Pokemon objects
|
|
*/
|
|
|
|
public function findPokemonsWithSearchTerm($searchTerm): array
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->andWhere('p.nom LIKE :searchTerm
|
|
OR typ.name LIKE :searchTerm
|
|
OR gen.name LIKE :searchTerm')
|
|
->leftJoin('p.type1', 'typ')
|
|
->leftJoin('p.generation', 'gen')
|
|
->setParameter('searchTerm', '%' . $searchTerm . '%')
|
|
->orderBy('p.numero', 'ASC')
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
|
|
|
|
// /**
|
|
// * @return Pokemon[] Returns an array of Pokemon objects
|
|
// */
|
|
/*
|
|
public function findByExampleField($value)
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->andWhere('p.exampleField = :val')
|
|
->setParameter('val', $value)
|
|
->orderBy('p.id', 'ASC')
|
|
->setMaxResults(10)
|
|
->getQuery()
|
|
->getResult()
|
|
;
|
|
}
|
|
*/
|
|
|
|
/*
|
|
public function findOneBySomeField($value): ?Pokemon
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->andWhere('p.exampleField = :val')
|
|
->setParameter('val', $value)
|
|
->getQuery()
|
|
->getOneOrNullResult()
|
|
;
|
|
}
|
|
*/
|
|
}
|
|
|