Commit 387d3b53 authored by Mat's avatar Mat

wip.. dump() give a correct result, but have error !!

parent ecf3f541
Pipeline #86056 failed with stages
in 48 seconds
...@@ -227,28 +227,35 @@ class SimilarityPersonSearch extends AbstractSearch ...@@ -227,28 +227,35 @@ class SimilarityPersonSearch extends AbstractSearch
$qb = $this->em->createQueryBuilder(); $qb = $this->em->createQueryBuilder();
$qb->from('ChillPersonBundle:Person', 'simi'); $qb
->select('sp')
->from('ChillPersonBundle:Person', 'sp');
if ($terms['_default'] !== '') { if ($terms['_default'] !== '') {
$grams = explode(' ', $terms['_default']); $grams = explode(' ', $terms['_default']);
foreach($grams as $key => $gram) { foreach($grams as $key => $gram) {
$qb->andWhere('SIMILARITY(simi.fullnameCanonical, UNACCENT(LOWER(:default_'.$key.')) ) >= 0.15') $qb->andWhere('SIMILARITY(sp.fullnameCanonical, UNACCENT(LOWER(:default_'.$key.')) ) >= 0.15')
->setParameter('default_'.$key, '%'.$gram.'%'); ->setParameter('default_'.$key, '%'.$gram.'%');
} }
/// ///
//dump($this->personSearch->createQuery($terms)->addSelect('p.id')->getDQL()); /// Testé avec http://localhost:8001/fr/search?q=matthieu
/// personSearch: 1 result
/// similaritySearch: 6 results - 1 = 5 results
///
$subquery = $this->personSearch->createQuery($terms)
->addSelect('p.id');
$qb->andWhere($qb->expr() $qb->andWhere($qb->expr()
->notIn( ->notIn(
'simi.id', 'sp.id',
$this->personSearch->createQuery($terms) $subquery->getDQL()
->select('p.id')
->getDQL()
) )
); );
dump($subquery->getDQL());
dump($subquery->getQuery()->getResult());
/// ///
} }
...@@ -256,14 +263,21 @@ class SimilarityPersonSearch extends AbstractSearch ...@@ -256,14 +263,21 @@ class SimilarityPersonSearch extends AbstractSearch
$reachableCenters = $this->helper->getReachableCenters($this->user, $reachableCenters = $this->helper->getReachableCenters($this->user,
new Role('CHILL_PERSON_SEE')); new Role('CHILL_PERSON_SEE'));
$qb->andWhere($qb->expr() $qb->andWhere($qb->expr()
->in('simi.center', ':centers')) ->in('sp.center', ':centers'))
->setParameter('centers', $reachableCenters) ->setParameter('centers', $reachableCenters)
; ;
$this->_cacheQuery[$cacheKey] = $qb; $this->_cacheQuery[$cacheKey] = $qb;
dump($qb->getDQL()); dump($qb->getDQL());
dump($qb->getQuery()->getResult()); //////////// <---- le résultat attendu !!
return clone $qb; return clone $qb;
///
/// [Semantical Error] line 0, col 13 near 'p.id) FROM ChillPersonBundle:Person':
/// Error: 'p' is used outside the scope of its declaration.
///
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment