Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 860-886 (lines=27) @@
857
   *
858
   * @throws QueryException
859
   */
860
  public function delete(string $table, $where, string $databaseName = null)
861
  {
862
    // init
863
    $table = \trim($table);
864
865
    if ($table === '') {
866
      $this->debug->displayError('Invalid table name, table name in empty.', false);
867
868
      return false;
869
    }
870
871
    if (\is_string($where)) {
872
      $WHERE = $this->escape($where, false);
873
    } elseif (\is_array($where)) {
874
      $WHERE = $this->_parseArrayPair($where, 'AND');
875
    } else {
876
      $WHERE = '';
877
    }
878
879
    if ($databaseName) {
880
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
881
    }
882
883
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
884
885
    return $this->query($sql);
886
  }
887
888
  /**
889
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 2223-2249 (lines=27) @@
2220
   *
2221
   * @throws QueryException
2222
   */
2223
  public function select(string $table, $where = '1=1', string $databaseName = null)
2224
  {
2225
    // init
2226
    $table = \trim($table);
2227
2228
    if ($table === '') {
2229
      $this->debug->displayError('Invalid table name, table name in empty.', false);
2230
2231
      return false;
2232
    }
2233
2234
    if (\is_string($where)) {
2235
      $WHERE = $this->escape($where, false);
2236
    } elseif (\is_array($where)) {
2237
      $WHERE = $this->_parseArrayPair($where, 'AND');
2238
    } else {
2239
      $WHERE = '';
2240
    }
2241
2242
    if ($databaseName) {
2243
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2244
    }
2245
2246
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
2247
2248
    return $this->query($sql);
2249
  }
2250
2251
  /**
2252
   * Selects a different database than the one specified on construction.