35358-vm/db/config.php
Flatlogic Bot 3d23e3f6ab v 25-10-30
2025-10-30 15:35:40 +00:00

39 lines
1.0 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) {
try {
$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,
]);
} catch (PDOException $e) {
// If the database doesn't exist, you might want to handle that here
// For now, we'll just re-throw the exception.
throw $e;
}
}
return $pdo;
}
function run_migrations() {
$pdo = db();
$migrations_dir = __DIR__ . '/migrations';
if (!is_dir($migrations_dir)) {
return;
}
$files = glob($migrations_dir . '/*.sql');
foreach ($files as $file) {
$sql = file_get_contents($file);
if ($sql) {
$pdo->exec($sql);
}
}
}