Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 747-773 (lines=27) @@
744
   *
745
   *    * @throws QueryException
746
   */
747
  public function delete(string $table, $where, string $databaseName = null)
748
  {
749
    // init
750
    $table = \trim($table);
751
752
    if ($table === '') {
753
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
754
755
      return false;
756
    }
757
758
    if (\is_string($where)) {
759
      $WHERE = $this->escape($where, false);
760
    } elseif (\is_array($where)) {
761
      $WHERE = $this->_parseArrayPair($where, 'AND');
762
    } else {
763
      $WHERE = '';
764
    }
765
766
    if ($databaseName) {
767
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
768
    }
769
770
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
771
772
    return $this->query($sql);
773
  }
774
775
  /**
776
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 1791-1817 (lines=27) @@
1788
   *
1789
   * @throws QueryException
1790
   */
1791
  public function select(string $table, $where = '1=1', string $databaseName = null)
1792
  {
1793
    // init
1794
    $table = \trim($table);
1795
1796
    if ($table === '') {
1797
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
1798
1799
      return false;
1800
    }
1801
1802
    if (\is_string($where)) {
1803
      $WHERE = $this->escape($where, false);
1804
    } elseif (\is_array($where)) {
1805
      $WHERE = $this->_parseArrayPair($where, 'AND');
1806
    } else {
1807
      $WHERE = '';
1808
    }
1809
1810
    if ($databaseName) {
1811
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1812
    }
1813
1814
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
1815
1816
    return $this->query($sql);
1817
  }
1818
1819
  /**
1820
   * Selects a different database than the one specified on construction.