Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 722-748 (lines=27) @@
719
   *
720
   *    * @throws QueryException
721
   */
722
  public function delete(string $table, $where, string $databaseName = null)
723
  {
724
    // init
725
    $table = \trim($table);
726
727
    if ($table === '') {
728
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
729
730
      return false;
731
    }
732
733
    if (\is_string($where)) {
734
      $WHERE = $this->escape($where, false);
735
    } elseif (\is_array($where)) {
736
      $WHERE = $this->_parseArrayPair($where, 'AND');
737
    } else {
738
      $WHERE = '';
739
    }
740
741
    if ($databaseName) {
742
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
743
    }
744
745
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
746
747
    return $this->query($sql);
748
  }
749
750
  /**
751
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 1768-1794 (lines=27) @@
1765
   *
1766
   * @throws QueryException
1767
   */
1768
  public function select(string $table, $where = '1=1', string $databaseName = null)
1769
  {
1770
    // init
1771
    $table = \trim($table);
1772
1773
    if ($table === '') {
1774
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
1775
1776
      return false;
1777
    }
1778
1779
    if (\is_string($where)) {
1780
      $WHERE = $this->escape($where, false);
1781
    } elseif (\is_array($where)) {
1782
      $WHERE = $this->_parseArrayPair($where, 'AND');
1783
    } else {
1784
      $WHERE = '';
1785
    }
1786
1787
    if ($databaseName) {
1788
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1789
    }
1790
1791
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
1792
1793
    return $this->query($sql);
1794
  }
1795
1796
  /**
1797
   * Selects a different database than the one specified on construction.