Fix: Load database credentials in constructor to avoid constant expression errors
This commit is contained in:
parent
52556e9f9c
commit
48ee8b4156
|
|
@ -26,14 +26,14 @@ class Database extends Config
|
||||||
*/
|
*/
|
||||||
public array $default = [
|
public array $default = [
|
||||||
'DSN' => '',
|
'DSN' => '',
|
||||||
'hostname' => env('database.default.hostname', 'localhost'),
|
'hostname' => 'localhost',
|
||||||
'username' => env('database.default.username', 'root'),
|
'username' => 'root',
|
||||||
'password' => env('database.default.password', ''),
|
'password' => '',
|
||||||
'database' => env('database.default.database', 'hms_ci4_2026'),
|
'database' => 'hms_ci4_2026',
|
||||||
'DBDriver' => env('database.default.DBDriver', 'MySQLi'),
|
'DBDriver' => 'MySQLi',
|
||||||
'DBPrefix' => '',
|
'DBPrefix' => '',
|
||||||
'pConnect' => false,
|
'pConnect' => false,
|
||||||
'DBDebug' => env('database.default.DBDebug', true),
|
'DBDebug' => true,
|
||||||
'charset' => 'utf8mb4',
|
'charset' => 'utf8mb4',
|
||||||
'DBCollat' => 'utf8mb4_general_ci',
|
'DBCollat' => 'utf8mb4_general_ci',
|
||||||
'swapPre' => '',
|
'swapPre' => '',
|
||||||
|
|
@ -41,7 +41,7 @@ class Database extends Config
|
||||||
'compress' => false,
|
'compress' => false,
|
||||||
'strictOn' => false,
|
'strictOn' => false,
|
||||||
'failover' => [],
|
'failover' => [],
|
||||||
'port' => env('database.default.port', 3306),
|
'port' => 3306,
|
||||||
'numberNative' => false,
|
'numberNative' => false,
|
||||||
'foundRows' => false,
|
'foundRows' => false,
|
||||||
'dateFormat' => [
|
'dateFormat' => [
|
||||||
|
|
@ -194,6 +194,15 @@ class Database extends Config
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
// Load database credentials from .env
|
||||||
|
$this->default['hostname'] = env('database.default.hostname', 'localhost');
|
||||||
|
$this->default['username'] = env('database.default.username', 'root');
|
||||||
|
$this->default['password'] = env('database.default.password', '');
|
||||||
|
$this->default['database'] = env('database.default.database', 'hms_ci4_2026');
|
||||||
|
$this->default['DBDriver'] = env('database.default.DBDriver', 'MySQLi');
|
||||||
|
$this->default['DBDebug'] = env('database.default.DBDebug', true);
|
||||||
|
$this->default['port'] = env('database.default.port', 3306);
|
||||||
|
|
||||||
// Ensure that we always set the database group to 'tests' if
|
// Ensure that we always set the database group to 'tests' if
|
||||||
// we are currently running an automated test suite, so that
|
// we are currently running an automated test suite, so that
|
||||||
// we don't overwrite live data on accident.
|
// we don't overwrite live data on accident.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user