From 9f3b5665755996c25145a55569301a2ab262dd86 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:47:09 +0100 Subject: [PATCH] make functions to get links --- Models/RecipeModel.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index 31b0831..5579011 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -81,6 +81,14 @@ final class RecipeModel return self::createFromRow($row, $I_id); } + public function getImageLink(){ + return '/static/img/recipes/'.$this->I_ID; + } + + public function getLink(){ + return '/recipe/view/'.$this->I_ID; + } + public function getImage(){ $O_model = Model::get(); $stmt = $O_model->prepare("SELECT IMG FROM RECIPE WHERE ID=:id"); @@ -162,9 +170,7 @@ final class RecipeModel ) -- get a row per occurrence and sort by occurrences number - select RECIPE.*, - CONCAT('/recipe/view/', RECIPE.ID) AS RECIPE_LINK, - CONCAT('/static/img/recipes/', RECIPE.ID) AS IMG_LINK, + select RECIPE.* 1 AS NOTE from CTE JOIN RECIPE