Merge branch 'laura' of https://github.com/Yasder5/projet_php into laura
This commit is contained in:
commit
c0dd044c57
123 changed files with 2357 additions and 13471 deletions
|
|
@ -108,8 +108,8 @@
|
|||
*/
|
||||
public function insert(object $objProject):bool{
|
||||
|
||||
$strRq = "INSERT INTO project (project_title, project_description, project_thumbnail, project_content, project_status, project_creation_date)
|
||||
VALUES (:title, :description, :thumbnail, :content, :status, DATE(NOW()))";
|
||||
$strRq = "INSERT INTO project (project_title, project_description, project_thumbnail, project_content, project_status, project_creation_date, project_user_id, project_category)
|
||||
VALUES (:title, :description, :thumbnail, :content, :status, DATE(NOW()), :project_user_id, :project_category)";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
|
|
@ -118,6 +118,8 @@
|
|||
$rqPrep->bindValue(":thumbnail", $objProject->getThumbnail(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":content", $objProject->getContent(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":status", $objProject->getStatus(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":project_user_id", $objProject->getUser_id(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":project_category", $objProject->getCategory(), PDO::PARAM_STR);
|
||||
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
|
|
@ -126,7 +128,7 @@
|
|||
* Fonction de recherche d'un seul projet
|
||||
* @param int $intId
|
||||
* @return array
|
||||
*/
|
||||
*/
|
||||
public function findOne(int $intId) :array{
|
||||
$strRq = "SELECT project.*,
|
||||
CONCAT(users.user_firstname, ' ', users.user_name) AS 'project_creatorname',
|
||||
|
|
@ -144,6 +146,12 @@
|
|||
return $rqPrep->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de changement de status (accepter) d'un projet en BDD
|
||||
* @author Guillaume
|
||||
* @param int $id l'id du projet
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function accept(int $id){
|
||||
|
||||
$strRq = "UPDATE project
|
||||
|
|
@ -153,6 +161,12 @@
|
|||
return $this->_db->query($strRq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction de changement de status (refusé) d'un projet en BDD
|
||||
* @author Guillaume
|
||||
* @param int $id l'id du projet
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function refuse(int $id){
|
||||
|
||||
$strRq = "UPDATE project
|
||||
|
|
@ -161,7 +175,13 @@
|
|||
|
||||
return $this->_db->query($strRq);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction de suppression d'un projet en BDD
|
||||
* @author Guillaume
|
||||
* @param int $id l'id du projet
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function delete(int $id){
|
||||
|
||||
$strRq = "DELETE FROM project
|
||||
|
|
@ -172,21 +192,58 @@
|
|||
|
||||
/**
|
||||
* Fonction de mise à jour d'un projet en BDD
|
||||
* @author Guillaume
|
||||
* @param object $objProject L'objet utilisateur
|
||||
* @return bool Est-ce que la requête s'est bien passée
|
||||
*/
|
||||
public function updateProject(object $objProject):bool{
|
||||
|
||||
$strRq = "UPDATE project
|
||||
SET project_title = :title,
|
||||
project_description = :description,
|
||||
project_content = :content,
|
||||
project_thumbnail = :thumbnail
|
||||
WHERE project_id = :id";
|
||||
|
||||
$strRq = "UPDATE project
|
||||
SET project_title = :title, project_description = :description, project_content = :content
|
||||
WHERE project_id = :id";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
$rqPrep->bindValue(":title", $objProject->getTitle(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":description", $objProject->getDescription(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":content", $objProject->getContent(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":thumbnail", $objProject->getThumbnail(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":id", $objProject->getId(), PDO::PARAM_INT);
|
||||
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
|
||||
public function getImagesByProjectId(int $projectId): array {
|
||||
$strRq = "SELECT image_id, image_name, image_alt
|
||||
FROM image
|
||||
WHERE image_project = :id AND image_status = 1";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
$rqPrep->bindValue(":id", $projectId, PDO::PARAM_INT);
|
||||
$rqPrep->execute();
|
||||
|
||||
return $rqPrep->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
public function addImageInProject(string $fileName, int $projectId, string $alt = "Image projet"): bool {
|
||||
$strRq = "INSERT INTO image (
|
||||
image_name,
|
||||
image_alt,
|
||||
image_status,
|
||||
image_project
|
||||
)
|
||||
VALUES (:name, :alt, :status, :project)";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
$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
|
||||
$rqPrep->bindValue(":project", $projectId, PDO::PARAM_INT);
|
||||
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue