Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/DB.php 1 location

@@ 798-825 (lines=28) @@
795
   *
796
   * @return bool
797
   */
798
  protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false)
799
  {
800
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
801
      static $RECONNECT_COUNTER;
802
803
      // exit if we have more then 3 "DB server has gone away"-errors
804
      if ($RECONNECT_COUNTER > 3) {
805
        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
806
        throw new DBGoneAwayException($errorMsg);
807
      }
808
809
      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
810
811
      // reconnect
812
      $RECONNECT_COUNTER++;
813
      $this->reconnect(true);
814
815
      // re-run the current query
816
      return $this->query($sql, $sqlParams);
817
    }
818
819
    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
820
821
    // this query returned an error, we must display it (only for dev) !!!
822
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
823
824
    return false;
825
  }
826
827
  /**
828
   * Reconnect to the MySQL-Server.

src/voku/db/Prepare.php 1 location

@@ 419-446 (lines=28) @@
416
   *
417
   * @return bool
418
   */
419
  private function queryErrorHandling($errorMsg, $sql)
420
  {
421
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
422
      static $RECONNECT_COUNTER;
423
424
      // exit if we have more then 3 "DB server has gone away"-errors
425
      if ($RECONNECT_COUNTER > 3) {
426
        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
427
        throw new DBGoneAwayException($errorMsg);
428
      }
429
430
      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
431
432
      // reconnect
433
      $RECONNECT_COUNTER++;
434
      $this->_db->reconnect(true);
435
436
      // re-run the current query
437
      return $this->execute();
438
    }
439
440
    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
441
442
    // this query returned an error, we must display it (only for dev) !!!
443
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
444
445
    return false;
446
  }
447
448
}
449