Commit 95972af0 authored by Charles DORMEVAL's avatar Charles DORMEVAL
Browse files

ajout variable de session pour transmettre les résultats de la recherche

parent 1919ee2d
......@@ -31,18 +31,18 @@ class MoteurDeRecherche
$this->authors=""; //changer avec une méthode qui permet de récupérer les autheurs de la bd
}
//fonctionnel
public function rechercheAvecAuteurDate($auteur,$date){
$requestComplement = "and date_oeuvre like ? and nom_auteur like ?";
$fullRequest = $this->connexion->prepare($this->requestPattern . $requestComplement);
$paramDate="'%".$date."%'";
$paramDate="%$date%";
$fullRequest->bindParam(1, $paramDate);
$paramAuteur="%".$auteur."%";
$fullRequest->bindParam(2, $paramAuteur);
$fullRequest->execute();
if(empty($fullRequest->fetchAll())){
$_SESSION['resRecherche']=$fullRequest->fetchAll();
if(empty($_SESSION['resRecherche'])){
$this->leveinsteinAuteur($auteur);
}else{
return $fullRequest->fetchAll();
}
}
......@@ -52,22 +52,24 @@ class MoteurDeRecherche
$paramAuteur="%".$auteur."%";
$fullRequest->bindParam(1, $paramAuteur);
$fullRequest->execute();
if(empty($fullRequest->fetchAll())){
$_SESSION['resRecherche']=$fullRequest->fetchAll();
if(empty($_SESSION['resRecherche'])){
$this->leveinsteinAuteur($auteur);
}else{
return $fullRequest->fetchAll();
}
}
//bugs
public function rechercheAvecMotsClesDate($recherche, $date){
$keyWords=explode(" ",$recherche);
$requestComplement="and date_oeuvre like ?";
foreach($keyWords as $keyWord){
$requestComplement=$requestComplement." and c.contenu like '% ".$keyWord." %'";
$requestComplement=$requestComplement." and c.contenu like % $keyWord %";
}
$fullRequest=$this->connexion->prepare($this->requestPattern.$requestComplement);
$param="'%".$date."%'";
$param="'%$date%'";
$fullRequest->bindParam(1, $param);
$fullRequest->execute();
if(empty($fullRequest->fetchAll())){
......@@ -82,7 +84,7 @@ class MoteurDeRecherche
$keyWords=explode(" ", $recherche);
$requestComplement="";
foreach($keyWords as $keyWord) {
$requestComplement = $requestComplement . " and c.contenu like '%{$keyWord}%'";
$requestComplement = $requestComplement . " and c.contenu like % $keyWord %";
}
$fullRequest=$this->connexion->prepare($this->requestPattern.$requestComplement);
$fullRequest->execute();
......
<?php
session_start();
require_once "./searchEngine/MoteurDeRecherche.php";
$searchEngine=new MoteurDeRecherche();
......@@ -10,12 +11,13 @@
$result=array();
$_SESSION['resRecherche']=NULL;
if($type=='auteur'){
if($date!=-1){
$searchEngine->rechercheAvecAuteurDate(strtoupper($element),$date);
}else{
$res=$searchEngine->rechercheAvecAuteur(strtoupper($element));
echo $res[1][1];
}
}else{
if($date!=-1){
......
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