Force a database reconnection in the daemon to prevent lost connections

This commit is contained in:
Michael 2018-06-10 22:04:09 +00:00
parent 1355798584
commit aa3f8ec09d
2 changed files with 33 additions and 4 deletions

View file

@ -92,6 +92,26 @@ class dba {
return self::$connected;
}
/**
* Disconnects the current database connection
*/
public static function disconnect()
{
if (is_null(self::$db)) {
return;
}
switch (self::$driver) {
case 'pdo':
self::$db = null;
break;
case 'mysqli':
self::$db->close();
self::$db = null;
break;
}
}
/**
* Return the database object.
* @return PDO|mysqli