Initial version upload

This commit is contained in:
Michael Staake
2025-11-03 11:04:46 -08:00
parent 8a3c48b98a
commit 0083f20e8c
26 changed files with 2281 additions and 0 deletions

33
models/QuickTask.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
class QuickTask {
private PDO $db;
public function __construct() {
$this->db = Database::getInstance();
}
public function getAll(): array {
$stmt = $this->db->query("SELECT * FROM quick_tasks ORDER BY name ASC");
return $stmt->fetchAll();
}
public function create(string $name): int {
try {
$stmt = $this->db->prepare("INSERT INTO quick_tasks (name) VALUES (?)");
$stmt->execute([$name]);
return (int)$this->db->lastInsertId();
} catch (PDOException $e) {
// Handle duplicate entry
if ($e->getCode() == 23000) {
return 0;
}
throw $e;
}
}
public function delete(int $id): bool {
$stmt = $this->db->prepare("DELETE FROM quick_tasks WHERE id = ?");
return $stmt->execute([$id]);
}
}