File size: 477 Bytes
36f2119 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php
try {
// Create (or connect to) the SQLite database in the same directory
$db = new PDO('sqlite:' . __DIR__ . '/database.sqlite');
// Set error mode to exceptions
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch results as associative arrays by default
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch (PDOException $e) {
die("Database connection failed: " . $e->getMessage());
}
?>
|