<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'ubsforums_campaign');
define('DB_PASS', 'camp@202526#');
define('DB_NAME', 'ubsforums_campaign');

define('DB_HOST', 'localhost');
define('DB_USER', 'ubsforums_campaign');
define('DB_PASS', 'camp@202526#');
define('DB_NAME', 'ubsforums_campaign');

function getDB(): ?mysqli {
    static $conn = null;
    if ($conn instanceof mysqli && $conn->ping()) return $conn;
    $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    if ($conn->connect_error) {
        error_log('BulkMailer DB error: ' . $conn->connect_error);
        return null;
    }
    $conn->set_charset('utf8mb4');
    // Auto-create tables on first connect

    return $conn;
}
?>