Fix where QueryBuilder

This commit is contained in:
Michael RICOIS 2017-02-09 12:13:16 +01:00
parent ebb28ccf66
commit 5b0653c733

View File

@ -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')