Code Duplication    Length = 28-28 lines in 2 locations

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

src/voku/db/DB.php 1 location

@@ 1320-1347 (lines=28) @@
1317
   *
1318
   * @return bool
1319
   */
1320
  protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false)
1321
  {
1322
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
1323
      static $RECONNECT_COUNTER;
1324
1325
      // exit if we have more then 3 "DB server has gone away"-errors
1326
      if ($RECONNECT_COUNTER > 3) {
1327
        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
1328
        throw new DBGoneAwayException($errorMsg);
1329
      }
1330
1331
      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
1332
1333
      // reconnect
1334
      $RECONNECT_COUNTER++;
1335
      $this->reconnect(true);
1336
1337
      // re-run the current query
1338
      return $this->query($sql, $sqlParams);
1339
    }
1340
1341
    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
1342
1343
    // this query returned an error, we must display it (only for dev) !!!
1344
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
1345
1346
    return false;
1347
  }
1348
1349
  /**
1350
   * Quote && Escape e.g. a table name string.