moving away from gross globals

This commit is contained in:
2026-07-03 21:05:39 -07:00
parent 230476e8e5
commit 7ee47a0b1e
7 changed files with 138 additions and 10 deletions
+5 -5
View File
@@ -25,7 +25,7 @@ class Database {
// Prepare the SQL statement
$stmt = $this->conn->prepare($query);
if (!$stmt) {
throw new Exception("Query preparation failed: " . $this->conn->error);
throw new \Exception("Query preparation failed: " . $this->conn->error);
}
// Bind parameters if needed
@@ -37,7 +37,7 @@ class Database {
// Execute the statement
if (!$stmt->execute()) {
$stmt->close();
throw new Exception("Query execution failed: " . $stmt->error);
throw new \Exception("Query execution failed: " . $stmt->error);
}
// Save last insert id if it's an INSERT query
@@ -70,7 +70,7 @@ class Database {
// Prepare the SQL statement
$stmt = $this->conn->prepare($query);
if (!$stmt) {
throw new Exception("Query preparation failed: " . $this->conn->error);
throw new \Exception("Query preparation failed: " . $this->conn->error);
}
// Bind parameters
@@ -82,7 +82,7 @@ class Database {
// Execute the statement
if (!$stmt->execute()) {
$stmt->close();
throw new Exception("Query execution failed: " . $stmt->error);
throw new \Exception("Query execution failed: " . $stmt->error);
}
// Get result
@@ -92,7 +92,7 @@ class Database {
$stmt->close();
return $row;
} catch (Exception $e) {
} catch (\Exception $e) {
echo "An error occurred: " . $e->getMessage();
return null;
}