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

@@ 1264-1291 (lines=28) @@
1261
   *
1262
   * @return bool
1263
   */
1264
  protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false)
1265
  {
1266
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
1267
      static $RECONNECT_COUNTER;
1268
1269
      // exit if we have more then 3 "DB server has gone away"-errors
1270
      if ($RECONNECT_COUNTER > 3) {
1271
        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
1272
        throw new DBGoneAwayException($errorMsg);
1273
      }
1274
1275
      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
1276
1277
      // reconnect
1278
      $RECONNECT_COUNTER++;
1279
      $this->reconnect(true);
1280
1281
      // re-run the current query
1282
      return $this->query($sql, $sqlParams);
1283
    }
1284
1285
    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
1286
1287
    // this query returned an error, we must display it (only for dev) !!!
1288
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
1289
1290
    return false;
1291
  }
1292
1293
  /**
1294
   * Quote && Escape e.g. a table name string.