From f9e2090a1028712ecc6e1b0c71390c821689b414 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 1 Apr 2021 09:43:48 +0300 Subject: Implemented getById from DB and changed some method names --- src/models/DB.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/models/DB.php') diff --git a/src/models/DB.php b/src/models/DB.php index 299b05a..b973e4b 100644 --- a/src/models/DB.php +++ b/src/models/DB.php @@ -37,6 +37,13 @@ class DB { $this->connection->exec($query); } + function getById(string $tableName, int $id) { + $sth = $this->connection->prepare("SELECT * FROM `{$tableName}` WHERE id = {$id}"); + $sth->execute(); + + return $sth->fetch(PDO::FETCH_OBJ); + } + function getAllValues(string $tableName) { $sth = $this->connection->prepare("SELECT * FROM `{$tableName}`"); $sth->execute(); -- cgit v1.3.1-26-gb76a