Files
4WDCSA.co.za/src/config/connection.php
twotalesanimation be2b757f4e Code restructure push
2025-12-04 15:09:44 +02:00

28 lines
787 B
PHP

<?php
// Disable mysqli exceptions so we can handle connection errors gracefully
mysqli_report(MYSQLI_REPORT_OFF);
$dbhost = $_ENV['DB_HOST'];
$dbuser = $_ENV['DB_USER'];
$dbpass = $_ENV['DB_PASS'];
$dbname = $_ENV['DB_NAME'];
$salt = $_ENV['SALT'];
// echo "hello. ". $dbhost;
if(!$conn = @mysqli_connect($dbhost, $dbuser, $dbpass, $dbname)){
// Log the error to file instead of stderr (no red output)
@error_log("Database Connection Error: " . mysqli_connect_error(), 3, dirname(__DIR__) . "/logs/db_errors.log");
$conn = null;
$db = null;
} else {
date_default_timezone_set('Africa/Johannesburg');
// Initialize DatabaseService for modern queries
require_once(__DIR__ . '/../../classes/DatabaseService.php');
$db = new DatabaseService($conn);
}