mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-21 13:47:47 +00:00
avoid PHP Fatal Error when mysqli PHP module is not available
This commit is contained in:
parent
f6c273d6c4
commit
af68fb65f2
@ -31,6 +31,11 @@ class Mysql extends BaseClass implements BaseInterface
|
||||
{
|
||||
parent::__construct($hostname, $data);
|
||||
|
||||
// Faster check if mysql is not loaded
|
||||
if (!$this->isAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $data['user'];
|
||||
$pass = $data['pass'];
|
||||
|
||||
@ -308,4 +313,14 @@ class Mysql extends BaseClass implements BaseInterface
|
||||
|
||||
return $this->_version;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
if (extension_loaded('mysqli')) {
|
||||
return parent::isAvailable();
|
||||
}
|
||||
|
||||
// when php module 'mysqli' not available or just disable by configuration (see .env PHP_MODULES_DISABLE)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user