diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index b8209eaeb..6555f7835 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -79,6 +79,11 @@ class SimilarPersonMatcher ->where('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) >= :precision') ->andWhere($qb->expr()->in('p.center', ':centers')); + $qb + ->setParameter('fullName', $this->personRender->renderString($person, [])) + ->setParameter('centers', $centers) + ->setParameter('precision', $precision); + if (null !== $person->getBirthdate()) { $qb->andWhere($qb->expr()->orX( $qb->expr()->eq('p.birthdate', ':personBirthdate'), @@ -90,13 +95,13 @@ class SimilarPersonMatcher if ($person->getId() !== null) { $qb->andWhere($qb->expr()->neq('p.id', ':personId')); - $query->setParameter('personId', $person->getId()); + $qb->setParameter('personId', $person->getId()); $notDuplicatePersons = $this->personNotDuplicateRepository->findNotDuplicatePerson($person); if (count($notDuplicatePersons)) { $qb->andWhere($qb->expr()->notIn('p.id', ':notDuplicatePersons')); - $query->setParameter('notDuplicatePersons', $notDuplicatePersons); + $qb->setParameter('notDuplicatePersons', $notDuplicatePersons); } } @@ -109,13 +114,10 @@ class SimilarPersonMatcher case self::SIMILAR_SEARCH_ORDER_BY_SIMILARITY: default: $qb->orderBy('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName)))', 'DESC'); + $qb->setParameter('fullName', $this->personRender->renderString($person, [])); } - $qb - ->setParameter('fullName', $this->personRender->renderString($person, [])) - ->setParameter('centers', $centers) - ->setParameter('precision', $precision); - + dump($qb->getQuery()); return $qb->getQuery()->getResult(); } }