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

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