Restriction de la recherche
regne = 'plantae' and groupe2_INPN in ('Angiospermes','Gymnospermes');
TODO : améliorer la recherche → chêne , if etc
public function getTaxrefPaginated($page, $per_page, $orderby, $find, $options = [])
{
$orderBy = explode(" ", $orderby);
$search = preg_replace('/[^\\p{L}\\p{N}_]+/u', ' ', $find);
$search = preg_replace('/[+\\-><\\(\\)~*\\"@]+/', ' ', $find);
$search = trim(
preg_replace(
"/[^a-z0-9']+([a-z0-9']{1,1}[^a-z0-9']+)*/i",
" ",
" $find "
)
);
$search = implode("* ", explode(" ", $search))."* ";
$query = $this->createQueryBuilder('t')
->where('MATCH (t.lb_nom,t.nom_vern,t.taxvern) AGAINST (:find boolean) > 1')
->setParameter('find', $search);
if (isset($options['regne'])) {
$query->andWhere('t.regne = :regne')->setParameter('regne', $options['regne']);
}
if (isset($options['groupe2_INPN'])) {
$query->andWhere('t.groupe2_INPN IN (:groupe2_INPN)')->setParameter(
'groupe2_INPN',
$options['groupe2_INPN']
);
}
$query->andWhere('t.cd_nom = t.cd_ref');
//$query->orderBy('t.' . $orderBy[0], $orderBy[1]);
$query->setFirstResult(($page - 1) * $per_page)->setMaxResults($per_page);
$adapter = new DoctrineORMAdapter($query);
return $adapter;
}