Merge remote-tracking branch 'upstream/develop' into quit-on-error
authorMichael <heluecht@pirati.ca>
Mon, 11 Jun 2018 03:15:59 +0000 (03:15 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 11 Jun 2018 03:15:59 +0000 (03:15 +0000)
1  2 
include/dba.php

diff --cc 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
         *