Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 733-759 (lines=27) @@
730
   *
731
   *    * @throws QueryException
732
   */
733
  public function delete(string $table, $where, string $databaseName = null)
734
  {
735
    // init
736
    $table = \trim($table);
737
738
    if ($table === '') {
739
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
740
741
      return false;
742
    }
743
744
    if (\is_string($where)) {
745
      $WHERE = $this->escape($where, false);
746
    } elseif (\is_array($where)) {
747
      $WHERE = $this->_parseArrayPair($where, 'AND');
748
    } else {
749
      $WHERE = '';
750
    }
751
752
    if ($databaseName) {
753
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
754
    }
755
756
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
757
758
    return $this->query($sql);
759
  }
760
761
  /**
762
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 1779-1805 (lines=27) @@
1776
   *
1777
   * @throws QueryException
1778
   */
1779
  public function select(string $table, $where = '1=1', string $databaseName = null)
1780
  {
1781
    // init
1782
    $table = \trim($table);
1783
1784
    if ($table === '') {
1785
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
1786
1787
      return false;
1788
    }
1789
1790
    if (\is_string($where)) {
1791
      $WHERE = $this->escape($where, false);
1792
    } elseif (\is_array($where)) {
1793
      $WHERE = $this->_parseArrayPair($where, 'AND');
1794
    } else {
1795
      $WHERE = '';
1796
    }
1797
1798
    if ($databaseName) {
1799
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1800
    }
1801
1802
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
1803
1804
    return $this->query($sql);
1805
  }
1806
1807
  /**
1808
   * Selects a different database than the one specified on construction.