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.
@@ 1777-1803 (lines=27) @@
1774
   *
1775
   * @throws QueryException
1776
   */
1777
  public function select(string $table, $where = '1=1', string $databaseName = null)
1778
  {
1779
    // init
1780
    $table = \trim($table);
1781
1782
    if ($table === '') {
1783
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
1784
1785
      return false;
1786
    }
1787
1788
    if (\is_string($where)) {
1789
      $WHERE = $this->escape($where, false);
1790
    } elseif (\is_array($where)) {
1791
      $WHERE = $this->_parseArrayPair($where, 'AND');
1792
    } else {
1793
      $WHERE = '';
1794
    }
1795
1796
    if ($databaseName) {
1797
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1798
    }
1799
1800
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
1801
1802
    return $this->query($sql);
1803
  }
1804
1805
  /**
1806
   * Selects a different database than the one specified on construction.