Setup/Maintenance

* toggle maintenance mode in a more reasonable manner (i.e. not when displaying help test)
 * move connectivity tests to class DB
 * restore generate everything functionality when running --sql and --build with an empty parameter set
This commit is contained in:
Sarjuuk
2021-02-20 19:19:24 +01:00
parent 43778b01e7
commit fbc5d43aab
13 changed files with 130 additions and 113 deletions

View File

@@ -49,6 +49,23 @@ class DB
self::$connectionCache[$idx] = true;
}
public static function test(array $options, ?string &$err = '') : bool
{
$defPort = ini_get('mysqli.default_port');
$port = 0;
if (strstr($options['host'], ':'))
[$options['host'], $port] = explode(':', $options['host']);
if ($link = @mysqli_connect($options['host'], $options['user'], $options['pass'], $options['db'], $port ?: $defPort))
{
mysqli_close($link);
return true;
}
$err = '['.mysqli_connect_errno().'] '.mysqli_connect_error();
return false;
}
public static function errorHandler($message, $data)
{
if (!error_reporting())