<?php
function getDatabaseConfig() {
    return [
        'host' => 'localhost',
        'username' => 'root',
        'password' => '',
        'database' => 'oldage_home',
    ];
}

function createDatabaseConnection($includeDatabase = true) {
    $config = getDatabaseConfig();
    $database = $includeDatabase ? $config['database'] : null;

    $conn = new mysqli(
        $config['host'],
        $config['username'],
        $config['password'],
        $database
    );

    if ($conn->connect_error) {
        throw new RuntimeException('Database connection failed: ' . $conn->connect_error);
    }

    $conn->set_charset('utf8mb4');
    return $conn;
}
?>