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