moving away from gross globals
This commit is contained in:
+5
-5
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user