$typeDeRecherche ],'- 1 - gondole.reqSelect.php');} // --------------------------------------------------- // Cas de recherche // $typeDeRecherche==0 => tous // $typeDeRecherche==1 => gondoles // $typeDeRecherche==2 => promos // $typeDeRecherche==3 => nouveautés // $typeDeRecherche==4 => categories (ancien familles) // $typeDeRecherche==5 => sous categories // $typeDeRecherche==6 => nomPrd // $typeDeRecherche==7 => references if ($typeDeRecherche==0) {$critere="WHERE P.statusPrd=1 "; $order="ORDER by idPrd";} if ($typeDeRecherche==1) {$critere="WHERE P.gondole=1 AND P.statusPrd=1 "; $order="ORDER by P.afficheGond";} if ($typeDeRecherche==2) {$critere="WHERE P.promo>0.00 AND P.statusPrd=1 "; $order="ORDER by P.idPrd";} if ($typeDeRecherche==3) {$critere="WHERE P.new=1 AND P.statusPrd=1 "; $order="ORDER by P.idPrd";} if ($typeDeRecherche==4) {$critere="WHERE P.idFam=" .$idFam. " AND P.statusPrd=1 "; $order="ORDER by P.idPrd";} if ($typeDeRecherche==5) {$critere="WHERE P.idCat=" .$idCat. " AND P.statusPrd=1 "; $order="ORDER by P.idPrd";} if ($typeDeRecherche==6) {$critere="WHERE PL.nomPrd like '%" .$nomPrd. "%' AND P.statusPrd=1 "; $order="ORDER by PL.nomPrd";} if ($typeDeRecherche==7) {$critere="WHERE P.refPrd='" .$ref. "'"; $order=" AND P.statusPrd=1 ORDER by P.refPrd";} // --------------------------------------------------- // en PDO debut ebauche a finir // --------------------------------------------------- // if ($typeDeRecherche==0) {$critere="WHERE statusPrd=1 "; $order="ORDER by idPrd";} // if ($typeDeRecherche==1) {$critere="WHERE gondole=1 AND statusPrd=1 "; $order="ORDER by afficheGond";} // if ($typeDeRecherche==2) {$critere="WHERE promo>0.00 AND statusPrd=1 "; $order="ORDER by idPrd";} // if ($typeDeRecherche==3) {$critere="WHERE new=1 AND statusPrd=1 "; $order="ORDER by idPrd";} // if ($typeDeRecherche==4) {$critere="WHERE idFam=:idFam AND statusPrd=1 "; $order="ORDER by idPrd"; } // if ($typeDeRecherche==5) {$critere="WHERE idCat=:idCat AND statusPrd=1 "; $order="ORDER by idPrd";} // if ($typeDeRecherche==6) {$critere="WHERE produitslibelle.nomPrd like :nomPrd AND produits.statusPrd=1 AND produitslibelle.idLg=:lg"; $order="ORDER by produitslibelle.nomPrd";} // if ($typeDeRecherche==7) {$critere="WHERE refPrd=:ref"; $order=" AND statusPrd=1 ORDER by refPrd";} // if ($typeDeRecherche!=6) { // $stmtCount = $pdo->prepare("SELECT COUNT(idPrd) AS nb FROM produits $critere"); // } else { // $stmtCount = $pdo->prepare(" // SELECT COUNT(produitslibelle.idPrd) AS nb // FROM produitslibelle, produits // $critere AND produits.idPrd=produitslibelle.idPrd // "); // } // if ($typeDeRecherche==4) { // $stmtCount->bindValue(':idFam', $idFam, PDO::PARAM_INT); // } // if ($typeDeRecherche==5) { // $stmtCount->bindValue(':idCat', $idCat, PDO::PARAM_INT); // } // if ($typeDeRecherche==6) { // $stmtCount->bindValue(':nomPrd', '%'.$nomPrd.'%', PDO::PARAM_STR); // $stmtCount->bindValue(':lg', $lg, PDO::PARAM_STR); // } // if ($typeDeRecherche==7) { // $stmtCount->bindValue(':ref', $ref, PDO::PARAM_STR); // } // $stmtCount->execute(); // $resultCmpt = $stmtCount->fetch(PDO::FETCH_ASSOC)['nb']; // --------------------------------------------------- // requete qui calcule le nombre de résultats // --------------------------------------------------- $i=0; $resConn=''; $resultCmpt=0; if ($typeDeRecherche!=6) {$reqSelect="SELECT count(P.idPrd) as nb FROM `produits` as P " .$critere. " ;";} else {$reqSelect="SELECT count(PL.idPrd) AS nb FROM `produitslibelle` AS PL JOIN `produits` as P ON P.idPrd=PL.idPrd " .$critere. " ;";} if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['reqSelect' => $reqSelect], '- 2 count - gondole.reqSelect.php');} try { $resConn=$idPdo->query($reqSelect); if ($resConn) { // $tabResult = $resConn->fetch(PDO::FETCH_ASSOC); $tabResult = $resConn->fetch(PDO::FETCH_ASSOC); $resultCmpt=intval($tabResult['nb']); } if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug(2, ['Nombre de résultats resultCmpt' => $resultCmpt], ''); // --------------------------------------------------- // calcul du bornage // nbResAff : le nb de resultat par pagination // --------------------------------------------------- $continuer=1; if ($nbResAff!='' && $nbResAff !=0 ) $nbResAff=intval($nbResAff); $ff=1; $mm=0; if ($nbResAff!='' && $nbResAff !=0 && $resultCmpt!=0) { if ($resultCmpt>=$nbResAff) { $ff=$resultCmpt/$nbResAff; if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug(2, ['ff 1' => $ff], '');} $ff=floor($ff); //valeur entiere $mm=fmod($resultCmpt, $nbResAff); //retourne le nombre de chiffres apres la virgule if ($mm>0) {$ff=$ff+1;}//nombre de pages final } } else { $ff=1; $continuer=0; } if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug(2, ['ff' => $ff, 'mm' => $mm, 'nbResAff' => $nbResAff, 'continuer' => $continuer], '- 3 bornage - gondole.reqSelect.php'); if ($continuer==1) { // liste des bornes if ($ff!='') { // php complain $b1[0]=0; for ($j=0; $j<$ff; $j++) { $b1[$j]=($j)*$nbResAff; if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug(2,['$b1[' .$j. ']' => $b1[$j]], ''); } } // --------------------------------------------------- // Requete construite // Borne1 est postée // --------------------------------------------------- // if ($typeDeRecherche!=6) { $reqSelect="SELECT P.*, PL.nomPrd, PL.descCourt, PL.descLong from `produits` AS P JOIN produitslibelle AS PL ON P.idPrd = PL.idPrd " .$critere. " AND PL.idLg='" .$lg. "' " .$order. " limit " .$borne1. "," .$nbResAff. ";"; // } // else { // $resConn=''; // $resConn=$idPdo->query($reqSelect); // $critere =" WHERE "; // $z=0; // if ($resConn && isset($idprd) ) { // while ($resTabPrd=$resConn->fetch(PDO::FETCH_ASSOC)) { // if ($z<1) {$critere=$critere. 'P.idprd=' .$resTabPrd['idPrd']. ' ';} // if ($z>=1) {$critere=$critere. 'or P.idprd=' .$resTabPrd['idPrd']. ' ';} // $z++; // } // } // else { // } if (isset($debug[2]) && $debug[2] == '1' ) { $debugMsg .= monDebug(2,['Critere' => $critere ],'');} // $order="order by P.idPrd"; // $reqSelect="SELECT * from `produits` " .$critere. " AND statusPrd=1 " .$order. " ;"; ==> pb avec limit ?? // $reqSelect="SELECT P.*, PL.nomPrd, PL.descCourt, PL.descLong from `produits` AS P JOIN produitslibelle AS PL ON P.idPrd = PL.idPrd " .$critere. " " .$order. " limit " .$borne1. "," .$nbResAff. ";"; // } if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .= monDebug(2,['Requete finale ' => $reqSelect], '- 4 req fin - gondole.reqSelect.php'); include ("gondole_fetch.php"); } } catch (PDOException $e) { // error if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Your fail message:' => $e->getMessage(),'reqSelect' => $reqSelect ], 'gondole.reqSelect.php'); } } ?>