aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/database.php9
1 files changed, 8 insertions, 1 deletions
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 @@
<?php
namespace Database;
use PDO;
+use Exception;
abstract class Table {
// Cannot be created, because FETCH_CLASS will assign to all attributes
@@ -16,7 +17,7 @@ abstract class Table {
if ($query->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);