merge guillaume->main

This commit is contained in:
Yasder5 2026-02-24 15:34:17 +01:00
commit 1d0fd2acff
50 changed files with 1068 additions and 505 deletions

View file

@ -25,9 +25,9 @@
/**
*Pour passer sur le serveur de YASS:
*"mysql:host=boulayoune.com;dbname=projet_folliow", // Serveur et BDD
*"projet_user", //Nom d'utilisateur de la base de données
*"F0lliowRules!",// Mot de passe de la base de données
*Site pour BDD: https://phpmyadmin.boulayoune.com/index.php?route=/sql&pos=0&db=projet_folliow&table=project
"projet_user", //Nom d'utilisateur de la base de données
"F0lliowRules!",// Mot de passe de la base de données
Site pour BDD: https://phpmyadmin.boulayoune.com/index.php?route=/sql&pos=0&db=projet_folliow&table=project
*Pour passer en local:
*"mysql:host=localhost;dbname=projet_folliow", // Serveur et BDD

View file

@ -121,7 +121,16 @@
$rqPrep->bindValue(":project_user_id", $objProject->getUser_id(), PDO::PARAM_STR);
$rqPrep->bindValue(":project_category", $objProject->getCategory(), PDO::PARAM_STR);
return $rqPrep->execute();
// On met une variable boolOk pour récupérer l'id du projet
$boolOk = $rqPrep->execute();
// Si boolOk est remplis
if ($boolOk) {
// On récupère l'ID auto-incrémenté et on l'injecte dans l'objet
$objProject->setId($this->_db->lastInsertId());
}
return $boolOk;
}
/**
@ -216,10 +225,16 @@
return $rqPrep->execute();
}
/**
* Fonction de récupération d'image d'un projet en BDD
* @author Guillaume
* @param int $objProject L'Id du projet choisit
* @return array Un tableau avec les informations de la bdd
*/
public function getImagesByProjectId(int $projectId): array {
$strRq = "SELECT image_id, image_name, image_alt
$strRq = "SELECT image_id, image_name, image_alt, image_status
FROM image
WHERE image_project = :id AND image_status = 1";
WHERE image_project = :id";
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(":id", $projectId, PDO::PARAM_INT);
@ -228,6 +243,56 @@
return $rqPrep->fetchAll(PDO::FETCH_ASSOC);
}
/**
* Fonction de récupération d'image d'un projet en BDD
* @author Guillaume
* @param int $id L'Id de l'image choisit
* @return array Un tableau avec les informations de la bdd
*/
public function deleteImage(int $id): bool {
$strRq = "DELETE FROM image WHERE image_id = :id";
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
return $rqPrep->execute();
}
/**
* Fonction de modifications de status de l'image d'un projet en BDD
* @author Guillaume
* @param int $id L'Id de l'image choisit, string $status le status choisit
* @return array Un tableau avec les informations de la bdd
*/
public function updateImageStatus(int $id, string $status): bool {
$strRq = "UPDATE image SET image_status = :status WHERE image_id = :id";
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(':status', $status, PDO::PARAM_STR);
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
return $rqPrep->execute();
}
/**
* Fonction de récupération d'image d'un projet en BDD
* @author Guillaume
* @param int $id L'Id de l'image choisit
* @return array Un tableau avec les informations de la bdd
*/
public function findImage(int $id): array|bool {
$strRq = "SELECT * FROM image WHERE image_id = :id";
$rqPrep = $this->_db->prepare($strRq);
$rqPrep->bindValue(':id', $id, PDO::PARAM_INT);
$rqPrep->execute();
return $rqPrep->fetch(PDO::FETCH_ASSOC);
}
/**
* Ajoute une image liée à un projet dans la table 'image'
* @author Guillaume
* @param string $fileName Nom du fichier image
* @param int $projectId ID du projet parent
* @param string $alt Texte alternatif
* @return bool
*/
public function addImageInProject(string $fileName, int $projectId, string $alt = "Image projet"): bool {
$strRq = "INSERT INTO image (
image_name,
@ -241,9 +306,10 @@
$rqPrep->bindValue(":name", $fileName, PDO::PARAM_STR);
$rqPrep->bindValue(":alt", $alt, PDO::PARAM_STR);
$rqPrep->bindValue(":status", "en_attente", PDO::PARAM_STR); // Valeur string brute
// On met le statut par défaut en "en_attente" pour la modération
$rqPrep->bindValue(":status", "en_attente", PDO::PARAM_STR);
$rqPrep->bindValue(":project", $projectId, PDO::PARAM_INT);
return $rqPrep->execute();
}
}
}