- Created DatabaseService.php with full OOP database abstraction layer - Methods: select(), selectOne(), insert(), update(), delete(), execute(), count(), exists() - Transaction support: beginTransaction(), commit(), rollback() - Error handling: getLastError(), getLastQuery() for debugging - Type-safe parameter binding with prepared statements - Updated connection.php to initialize $db service - Available globally as $db variable after connection.php include - Foundation for migrating from procedural $conn queries
20 lines
479 B
PHP
20 lines
479 B
PHP
<?php
|
|
|
|
$dbhost = $_ENV['DB_HOST'];
|
|
$dbuser = $_ENV['DB_USER'];
|
|
$dbpass = $_ENV['DB_PASS'];
|
|
$dbname = $_ENV['DB_NAME'];
|
|
$salt = $_ENV['SALT'];
|
|
|
|
|
|
|
|
if(!$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname)){
|
|
die("Failed to connect: " . mysqli_connect_error());
|
|
}
|
|
|
|
date_default_timezone_set('Africa/Johannesburg');
|
|
|
|
// Initialize DatabaseService for modern queries
|
|
require_once(__DIR__ . '/classes/DatabaseService.php');
|
|
$db = new DatabaseService($conn);
|