Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

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