avoid PHP Fatal Error when mysqli PHP module is not available

This commit is contained in:
Laurent Laville 2021-04-19 17:25:56 +02:00
parent f6c273d6c4
commit af68fb65f2

View File

@ -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;
}
}