From 7ef799668a9f8c1ef8b9bcaff94541990a164ac2 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:20:09 +0100 Subject: [PATCH] add IngredientModel::update() --- Models/IngredientModel.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Models/IngredientModel.php b/Models/IngredientModel.php index 4d29852..7c791c8 100644 --- a/Models/IngredientModel.php +++ b/Models/IngredientModel.php @@ -41,6 +41,15 @@ final class IngredientModel $stmt->execute(); } + public function update(){ + $O_model = Model::get(); + $stmt = $O_model->prepare("UPDATE RECIPE_INGREDIENT SET QUANTITY=:quantity + WHERE RECIPE_ID=:recipe_id AND INGREDIENT_ID=:ingredient_id"); + $stmt->bindParam("quantity", $this->S_QUANTITY); + $stmt->bindParam("recipe_id", $this->I_RECIPE_ID); + $stmt->bindParam("ingredient_id", $this->I_INGREDIENT_ID); + $stmt->execute(); + } public function delete(){ $O_model = Model::get(); @@ -52,6 +61,7 @@ final class IngredientModel $stmt->bindParam("id", $this->I_INGREDIENT_ID); $stmt->execute(); } + public static function getByRecipeAndName($I_recipe_id, $S_name){ $S_name = strtolower($S_name); $O_model = Model::get();