From: Michael Date: Mon, 11 Jun 2018 03:15:59 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into quit-on-error X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b02cdc8a7f84a4931e80027de42a80daa58581e1;p=friendica.git Merge remote-tracking branch 'upstream/develop' into quit-on-error --- b02cdc8a7f84a4931e80027de42a80daa58581e1 diff --cc include/dba.php index f915d78373,6b98f243e4..550fbe2557 --- a/include/dba.php +++ b/include/dba.php @@@ -104,21 -92,35 +94,50 @@@ echo "1" return self::$connected; } + public static function reconnect() { + // This variable is only defined here again to prevent warning messages + // It is a local variable and should hopefully not interfere with the global one. + $a = new App(dirname(__DIR__)); + + // We have to the the variable to "null" to force a new connection + self::$db = null; + include '.htconfig.php'; + + $ret = self::connect($db_host, $db_user, $db_pass, $db_data); + unset($db_host, $db_user, $db_pass, $db_data); + + return $ret; + } + + /** + * 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 + */ + public static function get_db() + { + return self::$db; + } + /** * @brief Returns the MySQL server version string *