Fix Database init parameter handling
This commit is contained in:
parent
5ba6def517
commit
171f2c7f11
1 changed files with 8 additions and 9 deletions
|
@ -95,15 +95,14 @@ class Database
|
|||
{
|
||||
if(!static::isInitialized()){
|
||||
if(is_array($host)){
|
||||
if(isset($host['host']) && isset($host['user']) && isset($host['password']) && isset($host['database'])){
|
||||
$user = $host['user'];
|
||||
$password = $host['password'];
|
||||
$database = $host['database'];
|
||||
$host = $host['host'];
|
||||
}
|
||||
else{
|
||||
throw new InvalidArgumentException;
|
||||
}
|
||||
$database = isset($host['database']) ? $host['database'] : $database;
|
||||
$password = isset($host['password']) ? $host['password'] : $password;
|
||||
$user = isset($host['user']) ? $host['user'] : $user;
|
||||
$host = isset($host['host']) ? $host['host'] : $host;
|
||||
}
|
||||
|
||||
if(is_null($host) || is_null($user) || is_null($password) || is_null($database)){
|
||||
throw new InvalidArgumentException('Missing parameters for database initialization.');
|
||||
}
|
||||
|
||||
static::setInstance(
|
||||
|
|
Loading…
Add table
Reference in a new issue