Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 885-911 (lines=27) @@
882
   *
883
   * @throws QueryException
884
   */
885
  public function delete(string $table, $where, string $databaseName = null)
886
  {
887
    // init
888
    $table = \trim($table);
889
890
    if ($table === '') {
891
      $this->debug->displayError('Invalid table name, table name in empty.', false);
892
893
      return false;
894
    }
895
896
    if (\is_string($where)) {
897
      $WHERE = $this->escape($where, false);
898
    } elseif (\is_array($where)) {
899
      $WHERE = $this->_parseArrayPair($where, 'AND');
900
    } else {
901
      $WHERE = '';
902
    }
903
904
    if ($databaseName) {
905
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
906
    }
907
908
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
909
910
    return $this->query($sql);
911
  }
912
913
  /**
914
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 2266-2292 (lines=27) @@
2263
   *
2264
   * @throws QueryException
2265
   */
2266
  public function select(string $table, $where = '1=1', string $databaseName = null)
2267
  {
2268
    // init
2269
    $table = \trim($table);
2270
2271
    if ($table === '') {
2272
      $this->debug->displayError('Invalid table name, table name in empty.', false);
2273
2274
      return false;
2275
    }
2276
2277
    if (\is_string($where)) {
2278
      $WHERE = $this->escape($where, false);
2279
    } elseif (\is_array($where)) {
2280
      $WHERE = $this->_parseArrayPair($where, 'AND');
2281
    } else {
2282
      $WHERE = '';
2283
    }
2284
2285
    if ($databaseName) {
2286
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2287
    }
2288
2289
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
2290
2291
    return $this->query($sql);
2292
  }
2293
2294
  /**
2295
   * Selects a different database than the one specified on construction.