diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index 8c4e6d9..5756b58 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -99,6 +99,22 @@ final class RecipeModel return $row["IMG"]; } + public function queryNote(){ + $O_model = Model::get(); + $stmt = $O_model->prepare(" + SELECT avg(NOTE) AS AVG FROM APPRECIATION + WHERE RECIPE_ID = :id + "); + $stmt->bindParam("id", $this->I_ID); + $stmt->execute(); + + $row = $stmt->fetch(); + if ($row === false) return null; + $avg = $row["AVG"]; + + return round($avg*2)/2; + } + public function getAuthor(){ if($this->O_AUTHOR === null){ $this->O_AUTHOR = UserModel::getByID($this->I_AUTHOR_ID); @@ -133,6 +149,7 @@ final class RecipeModel $this->getDifficulty(); $this->getIngredients(); } + public static function getFullRecipeById($I_id) { $O_recipe = self::getRecipeByID($I_id); diff --git a/Views/common/recipe.php b/Views/common/recipe.php index a11cdf0..0d62435 100644 --- a/Views/common/recipe.php +++ b/Views/common/recipe.php @@ -5,6 +5,6 @@ $O_recipe = $A_view["RECIPE"]; <?= $O_recipe->S_NAME ?>

S_NAME ?>

-

I_NOTE ?>

+

queryNote() ?>