$queryString="SELECT * FROM m_recette INNER JOIN m_recetteIngredient ON m_recette.id=m_recetteIngredient.recetteId WHERE 1=1";
if(!empty($categoryId)){
if(!empty($categoryId)){
$queryString.=" AND categoryId=:categoryId";
$queryString.=" AND categoryId=:categoryId";
}
}
if(!empty($name)){
if(!empty($name)){
$queryString.=" AND nom LIKE :name";
$queryString.=" AND nom LIKE :name";
}
}
if(!empty($ingredientId)){
if(!empty($ingredients)){
$queryString.=" AND ingredientId=:ingredientId";
$ingredientsIn=implode(',',$ingredients);
$queryString.=" AND ingredientId IN (:ingredients)";
}
}
if(!empty($difficulte)){
if(!empty($difficulte)){
$queryString.=" AND difficulte=:difficulte";
$queryString.=" AND difficulte=:difficulte";
...
@@ -254,7 +255,7 @@ function getRecettes($search=""){
...
@@ -254,7 +255,7 @@ function getRecettes($search=""){
$query->bindParam(':name',$name);
$query->bindParam(':name',$name);
}
}
if(!empty($ingredientId)){
if(!empty($ingredientId)){
$query->bindParam(':ingredientId',$ingredientId);
$query->bindParam(':ingredients',$ingredientsIn);
}
}
if(!empty($difficulte)){
if(!empty($difficulte)){
$query->bindParam(':difficulte',$difficulte);
$query->bindParam(':difficulte',$difficulte);
...
@@ -432,7 +433,7 @@ function getIngredients($recetteId=""){
...
@@ -432,7 +433,7 @@ function getIngredients($recetteId=""){
$query->execute();
$query->execute();
return$query->fetchAll(PDO::FETCH_ASSOC);
return$query->fetchAll(PDO::FETCH_ASSOC);
}else{
}else{
$query=Connexion::pdo()->prepare("SELECT * FROM m_ingredient WHERE id IN (SELECT ingredientId FROM m_ingredientRecette WHERE recetteId=:recetteId) ORDER BY nom");
$query=Connexion::pdo()->prepare("SELECT * FROM m_ingredient WHERE id IN (SELECT ingredientId FROM m_recetteIngredient WHERE recetteId=:recetteId) ORDER BY nom");