| @@ 742-768 (lines=27) @@ | ||
| 739 | * |
|
| 740 | * * @throws QueryException |
|
| 741 | */ |
|
| 742 | public function delete(string $table, $where, string $databaseName = null) |
|
| 743 | { |
|
| 744 | // init |
|
| 745 | $table = \trim($table); |
|
| 746 | ||
| 747 | if ($table === '') { |
|
| 748 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 749 | ||
| 750 | return false; |
|
| 751 | } |
|
| 752 | ||
| 753 | if (\is_string($where)) { |
|
| 754 | $WHERE = $this->escape($where, false); |
|
| 755 | } elseif (\is_array($where)) { |
|
| 756 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 757 | } else { |
|
| 758 | $WHERE = ''; |
|
| 759 | } |
|
| 760 | ||
| 761 | if ($databaseName) { |
|
| 762 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 763 | } |
|
| 764 | ||
| 765 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 766 | ||
| 767 | return $this->query($sql); |
|
| 768 | } |
|
| 769 | ||
| 770 | /** |
|
| 771 | * Ends a transaction and commits if no errors, then ends autocommit. |
|
| @@ 1799-1825 (lines=27) @@ | ||
| 1796 | * |
|
| 1797 | * @throws QueryException |
|
| 1798 | */ |
|
| 1799 | public function select(string $table, $where = '1=1', string $databaseName = null) |
|
| 1800 | { |
|
| 1801 | // init |
|
| 1802 | $table = \trim($table); |
|
| 1803 | ||
| 1804 | if ($table === '') { |
|
| 1805 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 1806 | ||
| 1807 | return false; |
|
| 1808 | } |
|
| 1809 | ||
| 1810 | if (\is_string($where)) { |
|
| 1811 | $WHERE = $this->escape($where, false); |
|
| 1812 | } elseif (\is_array($where)) { |
|
| 1813 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1814 | } else { |
|
| 1815 | $WHERE = ''; |
|
| 1816 | } |
|
| 1817 | ||
| 1818 | if ($databaseName) { |
|
| 1819 | $databaseName = $this->quote_string(\trim($databaseName)) . '.'; |
|
| 1820 | } |
|
| 1821 | ||
| 1822 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE)"; |
|
| 1823 | ||
| 1824 | return $this->query($sql); |
|
| 1825 | } |
|
| 1826 | ||
| 1827 | /** |
|
| 1828 | * Selects a different database than the one specified on construction. |
|