I have a strange problem with doctrine.
I have here, two functions to retrieve the datas.
the first one :
public function findAccRecent(): array
{
$etats = [1, 2];
return $this->createQueryBuilder('l')
->innerJoin('l.auteurs', 'a')
->innerJoin('l.editeur', 'e')
->innerJoin('l.etatLibris', 'x')
->andWhere('x.id IN (:etat)')
->setParameter('etat', $etats)
->orderBy('l.xl_date', 'DESC')
->setMaxResults(18) //Par prudence, mettre 3x plus de résultat que le nombre souhaité
->getQuery()
->getResult();
}
The second one :
public function findAllLimit(int $page, $filtre = "", int $limit = 25, ):array
{
$result = [];
$query = $this->createQueryBuilder('l')
->innerJoin('l.auteurs', 'a')
->innerJoin('l.editeur', 'e')
->innerJoin('l.etatLibris', 'x')
->andWhere('l.xl_livre LIKE :val')
->orWhere('a.nom LIKE :val')
->orWhere('a.prenom LIKE :val')
->orWhere('l.xl_num LIKE :val')
->orWhere('e.nom LIKE :val')
->setParameter('val', "%".$filtre."%")
->orderBy('l.xl_num', 'DESC')
->setMaxResults($limit)
->setFirstResult($page * $limit - $limit);
$paginator = new Paginator($query);
$data = $paginator->getQuery()->getResult();
if(empty($data)) return $result;
//Calcul nb de pages
$pages = ceil($paginator->count() / $limit);
$result['data'] = $data;
$result['pages'] = $pages;
$result['page'] = $page;
$result['limit'] = $limit;
return $result;
}
The first function have no problem fetching all rows.
The second one… ignore all rows that have the column “xl_ean” that are null (they are varchar, so it’s showing only a blank in the database)…
That’s what I don’t understand : why is it doing that. I didn’t checked this column, so it doesn’t make sense, and I don’t know how to correct the problem. I tried deleting the “where” lines in the function, but it hasn’t changed anything…
I hope you can help me with that strange problem. Thank you in advance.