From f9de8858cf277373c914c91e58bdd5f2aeb39fe8 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:45:19 +0100 Subject: [PATCH] make searchRecipesByName() return Recipe objects --- Models/RecipeModel.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index 93fdd58..31b0831 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -162,7 +162,7 @@ final class RecipeModel ) -- get a row per occurrence and sort by occurrences number - select RECIPE.ID, RECIPE.NAME, + select RECIPE.*, CONCAT('/recipe/view/', RECIPE.ID) AS RECIPE_LINK, CONCAT('/static/img/recipes/', RECIPE.ID) AS IMG_LINK, 1 AS NOTE @@ -177,7 +177,12 @@ final class RecipeModel $stmt->bindParam("query", $S_query); $stmt->execute(); + + $A_recipes = array(); + foreach($stmt->fetchAll() as $row){ + array_push($A_recipes, self::createFromRow($row, $row["ID"])); + } - return $stmt->fetchAll(); + return $A_recipes; } }