update
This commit is contained in:
@@ -6,19 +6,14 @@ header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
|
|||||||
header('Access-Control-Allow-Headers: Content-Type');
|
header('Access-Control-Allow-Headers: Content-Type');
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
|
||||||
|
|
||||||
// ── Koneksi DB pakai environment variable ──────────────────────────────────
|
|
||||||
// Set env var ini di Coolify → resource app PHP → Environment Variables:
|
|
||||||
// DB_HOST = mysql-database-bwg8woskog0osso8wg4s4ogk
|
|
||||||
// DB_PORT = 3306
|
|
||||||
// DB_NAME = default
|
|
||||||
// DB_USER = mysql
|
|
||||||
// DB_PASS = (password dari Coolify)
|
|
||||||
$db_host = getenv('DB_HOST') ?: 'localhost';
|
$db_host = getenv('DB_HOST') ?: 'localhost';
|
||||||
$db_port = getenv('DB_PORT') ?: '3306';
|
$db_port = getenv('DB_PORT') ?: '3306';
|
||||||
$db_name = getenv('DB_NAME') ?: 'sipkem';
|
$db_name = getenv('DB_NAME') ?: 'sipkem';
|
||||||
$db_user = getenv('DB_USER') ?: 'root';
|
$db_user = getenv('DB_USER') ?: 'root';
|
||||||
$db_pass = getenv('DB_PASS') ?: '';
|
$db_pass = getenv('DB_PASS') ?: '';
|
||||||
|
|
||||||
|
$pdo = new PDO("mysql:host=$host;dbname=$db;charset=utf8", $user, $pass);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pdo = new PDO(
|
$pdo = new PDO(
|
||||||
"mysql:host={$db_host};port={$db_port};dbname={$db_name};charset=utf8mb4",
|
"mysql:host={$db_host};port={$db_port};dbname={$db_name};charset=utf8mb4",
|
||||||
|
|||||||
Reference in New Issue
Block a user