Dominik
2015-01-14 2615e90b0708eb1a057e9b63cf2068942a5f79ec
server/lib/classes/db_mysql.inc.php
@@ -86,7 +86,7 @@
         $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!');
         return false;
      }
      if(!((bool)mysqli_query( $this->_iConnId, "USE $this->dbName"))) {
      if(!((bool)mysqli_query( $this->_iConnId, 'USE `' . $this->dbName . '`'))) {
         $this->close();
         $this->_sqlerror('Datenbank nicht gefunden / Database not found');
         return false;
@@ -176,6 +176,7 @@
   private function _query($sQuery = '') {
      global $app;
      //if($this->isConnected == false) return false;
      if ($sQuery == '') {
         $this->_sqlerror('Keine Anfrage angegeben / No query given');
         return false;
@@ -187,6 +188,17 @@
         $ok = mysqli_ping($this->_iConnId);
         if(!$ok) {
            if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) {
               if($this->errorNumber == '111') {
                  // server is not available
                  if($try > 9) {
                     if(isset($app) && isset($app->forceErrorExit)) {
                        $app->forceErrorExit('Database connection failure!');
                     }
                     // if we reach this, the app object is missing or has no exit method, so we continue as normal
                  }
                  sleep(30); // additional seconds, please!
               }
               if($try > 9) {
                  $this->_sqlerror('DB::query -> reconnect');
                  return false;
@@ -424,7 +436,7 @@
      if($this->show_error_messages && $conf['demo_mode'] === false) {
         echo $sErrormsg . $sAddMsg;
      } else if(is_object($app) && method_exists($app, 'log')) {
            $app->log($sErrormsg . $sAddMsg, LOGLEVEL_WARN);
            $app->log($sErrormsg . $sAddMsg . ' -> ' . $mysql_errno . ' (' . $mysql_error . ')', LOGLEVEL_WARN);
         }
   }