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