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

@@ 1339-1366 (lines=28) @@
1336
   *
1337
   * @return bool
1338
   */
1339
  protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false)
1340
  {
1341
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
1342
      static $RECONNECT_COUNTER;
1343
1344
      // exit if we have more then 3 "DB server has gone away"-errors
1345
      if ($RECONNECT_COUNTER > 3) {
1346
        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
1347
        throw new DBGoneAwayException($errorMsg);
1348
      }
1349
1350
      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
1351
1352
      // reconnect
1353
      $RECONNECT_COUNTER++;
1354
      $this->reconnect(true);
1355
1356
      // re-run the current query
1357
      return $this->query($sql, $sqlParams);
1358
    }
1359
1360
    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
1361
1362
    // this query returned an error, we must display it (only for dev) !!!
1363
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
1364
1365
    return false;
1366
  }
1367
1368
  /**
1369
   * Quote && Escape e.g. a table name string.