From 6f57b5a189438c4faf8f96f558384fe7f861a4a1 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 18:39:47 +0100 Subject: [PATCH] link model controller and view to be able to post an appr --- Controllers/ApprController.php | 4 ++-- Models/ApprModel.php | 6 +++--- Views/appreciations/view_all.php | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Controllers/ApprController.php b/Controllers/ApprController.php index d3d247c..9059782 100644 --- a/Controllers/ApprController.php +++ b/Controllers/ApprController.php @@ -9,10 +9,10 @@ final class ApprController $I_recipe_id = Utils::intOrDie(Utils::getOrDie($A_postParams, "recipe_id")); $S_comment = Utils::getOrDie($A_postParams, "comment"); - $I_score = Utils::intOrDie(Utils::getOrDie($A_postParams, "score")); + $I_note = Utils::intOrDie(Utils::getOrDie($A_postParams, "note")); $O_apprModel = new ApprModel(); - $O_apprModel->createAppr($_SESSION["ID"], $I_recipe_id, $S_comment, $I_score); + $O_apprModel->createAppr($_SESSION["ID"], $I_recipe_id, $S_comment, $I_note); header("Location: ".$_SERVER['HTTP_REFERER']); } diff --git a/Models/ApprModel.php b/Models/ApprModel.php index 6f49f9a..05833c6 100644 --- a/Models/ApprModel.php +++ b/Models/ApprModel.php @@ -29,14 +29,14 @@ final class ApprModel { return $stmt->fetchAll(); } - public function createAppr($I_user_id, $I_recipe_id, $S_Comment, $I_score) + public function createAppr($I_user_id, $I_recipe_id, $S_Comment, $I_note) { $O_model = Model::get(); $stmt = $O_model->prepare(" - INSERT INTO APPRECIATION (COMMENT,SCORE,DATE,AUTHOR_ID,RECIPE_ID) VALUES (:comment, :score, :date, :author_id, :recipe_id) + INSERT INTO APPRECIATION (COMMENT,NOTE,DATE,AUTHOR_ID,RECIPE_ID) VALUES (:comment, :note, :date, :author_id, :recipe_id) "); $stmt->bindParam("comment",$S_Comment); - $stmt->bindParam("score",$I_score); + $stmt->bindParam("note",$I_note); $_date = date("Y-m-d"); $stmt->bindParam("date",$_date); $stmt->bindParam("author_id",$I_user_id); diff --git a/Views/appreciations/view_all.php b/Views/appreciations/view_all.php index 013e5a3..458823e 100644 --- a/Views/appreciations/view_all.php +++ b/Views/appreciations/view_all.php @@ -1,6 +1,6 @@

Appréciations:

-
+ @@ -12,6 +12,8 @@ 4 5 + "> +