From e45454a4f7863d0c8f0d92b589e90f9ad067584e Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Mon, 20 May 2024 12:34:10 +0200 Subject: [PATCH] aggiunta possibilità di vedere i singoli prodotti tramite /products/{numero}/show (parte 118) --- src/App/Models/product.php | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/src/App/Models/product.php b/src/App/Models/product.php index 1b23a28..752f32e 100644 --- a/src/App/Models/product.php +++ b/src/App/Models/product.php @@ -16,6 +16,17 @@ return $stmt->fetchAll(PDO::FETCH_ASSOC); } + + public function find(string $id) { + $conn = $this->database->getConnection(); + $sql = "SELECT * + FROM product + WHERE id = :id"; + $stmt = $conn->prepare($sql); + $stmt->bindValue(":id", $id, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetch(PDO::FETCH_ASSOC); + } } -- Gitblit v1.8.0