1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
$champRecherche= array('nom', 'diplome1','diplome2','salaire','statut','mobs','tags');
foreach ($champRecherche as $key) {
if(!isset($_POST[$key] )){
$_POST[$key]="";
}
}
if(is_array($_POST['tags'])){
$tags = implode(",",$_POST['tags']);
}
if(is_array($_POST['mobs'])){
$mobs = implode(",",$_POST['mobs']);
}
$sqlCount="SELECT COUNT(ID) nb FROM candidat C";
$sqlWhere=" WHERE (C.nom LIKE :nom)
AND ( (:diplome1 = '' AND :diplome2 = '') OR (C.annee BETWEEN :diplome1 AND :diplome2) )
AND( (((C.salaire_actuel <>0
AND C.salaire_demande <>0)
AND (C.salaire_actuel <= :salaire OR C.salaire_demande <= :salaire))
OR (C.salaire_actuel =0 AND C.salaire_demande <= :salaire AND C.salaire_demande <>0)
OR (C.salaire_actuel <= :salaire AND C.salaire_actuel <>0 AND C.salaire_demande =0)
OR (C.salaire_actuel=0 AND C.salaire_demande =0)) OR :salaire = '' )
AND ( :statut = '' OR C.statut_ID = :statut )
AND ( :mobs = '' OR C.ID IN (SELECT candidat_ID FROM candidatmobilite WHERE mobilite_ID IN (:mobs)) )
AND ( :tags = '' OR C.ID IN (SELECT candidat_ID FROM candidattags WHERE tags_ID IN (:tags)) ) ";
$nom = $_POST['nom']."%";
$req = $pdo->prepare($sqlCount.$sqlWhere);
$req->bindParam(':nom', $nom, PDO::PARAM_STR);
$req->bindParam(':diplome1', $_POST['diplome1'], PDO::PARAM_INT);
$req->bindParam(':diplome2', $_POST['diplome2'], PDO::PARAM_INT);
$req->bindParam(':salaire', $_POST['salaire'], PDO::PARAM_INT);
$req->bindParam(':statut', $_POST['statut'], PDO::PARAM_INT);
$req->bindParam(':mobs', $mobs, PDO::PARAM_STR);
$req->bindParam(':tags', $tags, PDO::PARAM_STR); |
Partager