| @@ 801-827 (lines=27) @@ | ||
| 798 | * |
|
| 799 | * @throws QueryException |
|
| 800 | */ |
|
| 801 | public function delete(string $table, $where, string $databaseName = null) |
|
| 802 | { |
|
| 803 | // init |
|
| 804 | $table = \trim($table); |
|
| 805 | ||
| 806 | if ($table === '') { |
|
| 807 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 808 | ||
| 809 | return false; |
|
| 810 | } |
|
| 811 | ||
| 812 | if (\is_string($where)) { |
|
| 813 | $WHERE = $this->escape($where, false); |
|
| 814 | } elseif (\is_array($where)) { |
|
| 815 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 816 | } else { |
|
| 817 | $WHERE = ''; |
|
| 818 | } |
|
| 819 | ||
| 820 | if ($databaseName) { |
|
| 821 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 822 | } |
|
| 823 | ||
| 824 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 825 | ||
| 826 | return $this->query($sql); |
|
| 827 | } |
|
| 828 | ||
| 829 | /** |
|
| 830 | * Ends a transaction and commits if no errors, then ends autocommit. |
|
| @@ 1930-1956 (lines=27) @@ | ||
| 1927 | * |
|
| 1928 | * @throws QueryException |
|
| 1929 | */ |
|
| 1930 | public function select(string $table, $where = '1=1', string $databaseName = null) |
|
| 1931 | { |
|
| 1932 | // init |
|
| 1933 | $table = \trim($table); |
|
| 1934 | ||
| 1935 | if ($table === '') { |
|
| 1936 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 1937 | ||
| 1938 | return false; |
|
| 1939 | } |
|
| 1940 | ||
| 1941 | if (\is_string($where)) { |
|
| 1942 | $WHERE = $this->escape($where, false); |
|
| 1943 | } elseif (\is_array($where)) { |
|
| 1944 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1945 | } else { |
|
| 1946 | $WHERE = ''; |
|
| 1947 | } |
|
| 1948 | ||
| 1949 | if ($databaseName) { |
|
| 1950 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 1951 | } |
|
| 1952 | ||
| 1953 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 1954 | ||
| 1955 | return $this->query($sql); |
|
| 1956 | } |
|
| 1957 | ||
| 1958 | /** |
|
| 1959 | * Selects a different database than the one specified on construction. |
|