<?php
// app/config/koneksi.php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$ENV = require __DIR__ . "/env.php";

$host = $ENV['DB_HOST'];
$port = $ENV['DB_PORT'];
$user = $ENV['DB_USER'];
$pass = $ENV['DB_PASS'];
$db   = $ENV['DB_NAME'];

$koneksi = mysqli_connect($host, $user, $pass, $db, (int)$port);

if (!$koneksi) {
    die("Koneksi database gagal: " . mysqli_connect_error());
}

// Untuk keamanan: set charset UTF8MB4
mysqli_set_charset($koneksi, "utf8mb4");