Code Duplication    Length = 27-27 lines in 2 locations

src/voku/db/DB.php 2 locations

@@ 804-830 (lines=27) @@
801
   *
802
   * @throws QueryException
803
   */
804
  public function delete(string $table, $where, string $databaseName = null)
805
  {
806
    // init
807
    $table = \trim($table);
808
809
    if ($table === '') {
810
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
811
812
      return false;
813
    }
814
815
    if (\is_string($where)) {
816
      $WHERE = $this->escape($where, false);
817
    } elseif (\is_array($where)) {
818
      $WHERE = $this->_parseArrayPair($where, 'AND');
819
    } else {
820
      $WHERE = '';
821
    }
822
823
    if ($databaseName) {
824
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
825
    }
826
827
    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
828
829
    return $this->query($sql);
830
  }
831
832
  /**
833
   * Ends a transaction and commits if no errors, then ends autocommit.
@@ 1896-1922 (lines=27) @@
1893
   *
1894
   * @throws QueryException
1895
   */
1896
  public function select(string $table, $where = '1=1', string $databaseName = null)
1897
  {
1898
    // init
1899
    $table = \trim($table);
1900
1901
    if ($table === '') {
1902
      $this->_debug->displayError('Invalid table name, table name in empty.', false);
1903
1904
      return false;
1905
    }
1906
1907
    if (\is_string($where)) {
1908
      $WHERE = $this->escape($where, false);
1909
    } elseif (\is_array($where)) {
1910
      $WHERE = $this->_parseArrayPair($where, 'AND');
1911
    } else {
1912
      $WHERE = '';
1913
    }
1914
1915
    if ($databaseName) {
1916
      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1917
    }
1918
1919
    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)";
1920
1921
    return $this->query($sql);
1922
  }
1923
1924
  /**
1925
   * Selects a different database than the one specified on construction.