35249-vm/db/config.php
Flatlogic Bot f2abc84982 1.0
2025-10-26 12:26:57 +00:00

37 lines
1.1 KiB
PHP

<?php
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_30972');
define('DB_USER', 'app_30972');
define('DB_PASS', '9eb17a13-4a89-4e11-8517-0c201096e935');
function db() {
static $pdo;
if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
return $pdo;
}
function apply_schema() {
$pdo = db();
$schema = file_get_contents(__DIR__ . '/schema.sql');
if ($schema === false) {
throw new Exception("Could not read schema.sql");
}
$pdo->exec($schema);
}
// Automatically apply schema on inclusion.
// In a real app, you'd use a more robust migration system.
try {
apply_schema();
} catch (Exception $e) {
// You might want to log this error instead of echoing it
error_log("Schema application failed: " . $e->getMessage());
// Optionally, you could re-throw or handle it to prevent app execution
}