From 489adf71ddbea55a56b06c7a0cefc24e02defc82 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 8 Nov 2025 06:44:33 +0000 Subject: [PATCH] Edit db/config.php via Editor --- db/config.php | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/db/config.php b/db/config.php index 0560579..8df4656 100644 --- a/db/config.php +++ b/db/config.php @@ -1,32 +1,29 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false, - ]); - return $p; + $pdo = new PDO("sqlite:$dbFile"); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + + // Enable foreign keys & UTF-8 + $pdo->exec("PRAGMA foreign_keys = ON;"); + $pdo->exec("PRAGMA encoding = 'UTF-8';"); + + return $pdo; } catch (PDOException $e) { - // Friendly error message for users - error_log('Database connection failed: ' . $e->getMessage()); - throw new Exception("Database not ready. Please contact support."); + throw new Exception("SQLite error: " . $e->getMessage()); } } \ No newline at end of file