Summary Files Commits Branches @commit @diff @stats
path: root / src / models / DB.php
diff options
context:
space:
mode:
1 files changed, 18 insertions, 0 deletions
-rw-r--r--src/models/DB.php18
diff --git a/src/models/DB.php b/src/models/DB.php
index 77e08a5..299b05a 100644
--- a/src/models/DB.php
+++ b/src/models/DB.php
@@ -43,4 +43,22 @@ class DB {
return $sth->fetchAll(PDO::FETCH_OBJ);
}
+
+ function insertValue(string $tableName, ...$values) {
+ $query = "INSERT INTO {$tableName} VALUES(NULL, ";
+
+ foreach($values as $value) {
+ if (gettype($value) == "string") {
+ $query .= "'{$value}', ";
+ }
+ else {
+ $query .= "{$value}, ";
+ }
+ }
+ $query = rtrim($query, ", ");
+
+ $query .= ");";
+
+ $this->connection->exec($query);
+ }
}