Merge pull request #154 from ThomasRubini/recipe_update_delete

This commit is contained in:
Thomas Rubini 2023-01-26 21:45:24 +01:00 committed by GitHub
commit 6bac400a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -169,6 +169,11 @@ final class RecipeController
}
}
// delete all remaining ingredients, they have been deleted by the user
foreach($A_ingrsInDB as $O_ingr){
$O_ingr->delete();
}
header("Location: /recipe/view/".$O_recipe->I_ID);
}

View File

@ -53,11 +53,7 @@ final class IngredientModel
public function delete(){
$O_model = Model::get();
$stmt = $O_model->prepare("DELETE FROM INGREDIENT WHERE ID=:id");
$stmt->bindParam("id", $this->I_INGREDIENT_ID);
$stmt->execute();
$stmt = $O_model->prepare("DELETE FROM RECIPE_INGREDIENT WHERE INGREDIENT_ID=:id");
$stmt->execute();
$stmt->bindParam("id", $this->I_INGREDIENT_ID);
$stmt->execute();
}