| @@ 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. |
|
| @@ 1899-1925 (lines=27) @@ | ||
| 1896 | * |
|
| 1897 | * @throws QueryException |
|
| 1898 | */ |
|
| 1899 | public function select(string $table, $where = '1=1', string $databaseName = null) |
|
| 1900 | { |
|
| 1901 | // init |
|
| 1902 | $table = \trim($table); |
|
| 1903 | ||
| 1904 | if ($table === '') { |
|
| 1905 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 1906 | ||
| 1907 | return false; |
|
| 1908 | } |
|
| 1909 | ||
| 1910 | if (\is_string($where)) { |
|
| 1911 | $WHERE = $this->escape($where, false); |
|
| 1912 | } elseif (\is_array($where)) { |
|
| 1913 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1914 | } else { |
|
| 1915 | $WHERE = ''; |
|
| 1916 | } |
|
| 1917 | ||
| 1918 | if ($databaseName) { |
|
| 1919 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 1920 | } |
|
| 1921 | ||
| 1922 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 1923 | ||
| 1924 | return $this->query($sql); |
|
| 1925 | } |
|
| 1926 | ||
| 1927 | /** |
|
| 1928 | * Selects a different database than the one specified on construction. |
|