new configs for deployment

This commit is contained in:
Araya's Project
2026-06-11 00:12:43 +07:00
parent bc415cd947
commit 5b316b2ef6
7 changed files with 25 additions and 101 deletions
+2 -8
View File
@@ -1,6 +1,4 @@
<?php
// Konfigurasi koneksi database
// Mendukung environment variable Docker (DB_HOST) maupun hardcoded untuk Laragon
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
define('DB_NAME', 'sig_spbu');
define('DB_USER', getenv('DB_USER') ?: 'root');
@@ -10,11 +8,7 @@ define('DB_CHARSET', 'utf8mb4');
function getDB(): PDO {
static $pdo = null;
if ($pdo !== null) return $pdo;
$dsn = sprintf(
'mysql:host=%s;dbname=%s;charset=%s',
DB_HOST, DB_NAME, DB_CHARSET
);
$dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', DB_HOST, DB_NAME, DB_CHARSET);
try {
$pdo = new PDO($dsn, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
@@ -28,4 +22,4 @@ function getDB(): PDO {
exit;
}
return $pdo;
}
}