From 5b0653c733a141ee96d3a58804a3d3e4147ae6f5 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 9 Feb 2017 12:13:16 +0100 Subject: [PATCH] Fix where QueryBuilder --- library/WsScore/Interne/v0.6/Service.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/library/WsScore/Interne/v0.6/Service.php b/library/WsScore/Interne/v0.6/Service.php index 5aa5bf16..dcf14a15 100644 --- a/library/WsScore/Interne/v0.6/Service.php +++ b/library/WsScore/Interne/v0.6/Service.php @@ -2280,7 +2280,7 @@ class Interne extends Scores_Ws_Server foreach($filtre as $item) { switch($item->key) { case 'siren': - $qb->where('siren=:siren')->setParameter('siren', $item->value); + $siren = $item->value; break; case 'etat': @@ -2304,6 +2304,10 @@ class Interne extends Scores_Ws_Server // Select user id $qb->where('idUtilisateur=:id')->setParameter('id', $idUtilisateur); + if ($siren) { + $qb->andWhere('siren=:siren')->setParameter('siren', $siren); + } + // Paginate $qb->setMaxResults($nbRep)->setFirstResult($position); @@ -2388,8 +2392,8 @@ class Interne extends Scores_Ws_Server $qb->select(array('COUNT(*) AS nb')) ->from('jo.telephonie') ->where('actif=1') - ->where('typeTel IN ("'.join('","', $typeToSelect).'")') - ->where('siren=:siren')->setParameter('siren', $siren); + ->andWhere('typeTel IN ("'.join('","', $typeToSelect).'")') + ->andWhere('siren=:siren')->setParameter('siren', $siren); if ( intval($nic) > 0 ) { $qb->where('nic=:nic')->setParameter('nic', $nic); @@ -2415,15 +2419,15 @@ class Interne extends Scores_Ws_Server 'IF(dateSuppr!=0,1,0) AS deleted')) ->from('jo.telephonie') ->where('actif=1') - ->where('typeTel IN ("'.join('","', $typeToSelect).'")') - ->where('siren=:siren')->setParameter('siren', $siren); + ->andWhere('typeTel IN ("'.join('","', $typeToSelect).'")') + ->andWhere('siren=:siren')->setParameter('siren', $siren); if ( intval($nic) > 0 ) { - $qb->where('nic=:nic')->setParameter('nic', $nic); + $qb->andWhere('nic=:nic')->setParameter('nic', $nic); } if ($filtre != null) { - $qb->where('typeTel=:filtre')->setParameter('filtre', $filtre); + $qb->andWhere('typeTel=:filtre')->setParameter('filtre', $filtre); } $qb->orderBy('typeTel', 'ASC')