Code restructure push
This commit is contained in:
27
src/config/connection.php
Normal file
27
src/config/connection.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user