From eeca9f447abbecb5e2173154499a3cd7f75977ea Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 19 Jan 2025 19:24:34 +0200 Subject: feat(database): Add an update record function --- models/database.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'models') diff --git a/models/database.php b/models/database.php index 1fe05e0..45be65b 100644 --- a/models/database.php +++ b/models/database.php @@ -1,6 +1,7 @@ rowCount() == 0) { throw new Exception("Value for $class doesn't exist!"); } - assert($query->rowCount() == 1, "Vaue for $class must be uniqely specified!"); + assert($query->rowCount() == 1, "Value for $class must be uniqely specified!"); $query->setFetchMode(PDO::FETCH_CLASS, $class); return $query->fetch(); @@ -32,6 +33,12 @@ abstract class Table { return $id; } + static protected function _update(string $table, string $sets, string $identify) { + $conn = Table::connect(); + $query = $conn->query("UPDATE $table SET $sets WHERE $identify"); + $conn = null; + } + static protected function _get_all(string $table, string $class, string $additional = null) : array { $conn = Table::connect(); $query = $conn->query("SELECT * FROM $table " . $additional); -- cgit v1.2.3