| @@ 711-737 (lines=27) @@ | ||
| 708 | * |
|
| 709 | * * @throws QueryException |
|
| 710 | */ |
|
| 711 | public function delete($table, $where, $databaseName = null) |
|
| 712 | { |
|
| 713 | // init |
|
| 714 | $table = trim($table); |
|
| 715 | ||
| 716 | if ($table === '') { |
|
| 717 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 718 | ||
| 719 | return false; |
|
| 720 | } |
|
| 721 | ||
| 722 | if (is_string($where)) { |
|
| 723 | $WHERE = $this->escape($where, false); |
|
| 724 | } elseif (is_array($where)) { |
|
| 725 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 726 | } else { |
|
| 727 | $WHERE = ''; |
|
| 728 | } |
|
| 729 | ||
| 730 | if ($databaseName) { |
|
| 731 | $databaseName = $this->quote_string(trim($databaseName)) . '.'; |
|
| 732 | } |
|
| 733 | ||
| 734 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 735 | ||
| 736 | return $this->query($sql); |
|
| 737 | } |
|
| 738 | ||
| 739 | /** |
|
| 740 | * Ends a transaction and commits if no errors, then ends autocommit. |
|
| @@ 1751-1777 (lines=27) @@ | ||
| 1748 | * |
|
| 1749 | * @throws QueryException |
|
| 1750 | */ |
|
| 1751 | public function select($table, $where = '1=1', $databaseName = null) |
|
| 1752 | { |
|
| 1753 | // init |
|
| 1754 | $table = trim($table); |
|
| 1755 | ||
| 1756 | if ($table === '') { |
|
| 1757 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 1758 | ||
| 1759 | return false; |
|
| 1760 | } |
|
| 1761 | ||
| 1762 | if (is_string($where)) { |
|
| 1763 | $WHERE = $this->escape($where, false); |
|
| 1764 | } elseif (is_array($where)) { |
|
| 1765 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1766 | } else { |
|
| 1767 | $WHERE = ''; |
|
| 1768 | } |
|
| 1769 | ||
| 1770 | if ($databaseName) { |
|
| 1771 | $databaseName = $this->quote_string(trim($databaseName)) . '.'; |
|
| 1772 | } |
|
| 1773 | ||
| 1774 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 1775 | ||
| 1776 | return $this->query($sql); |
|
| 1777 | } |
|
| 1778 | ||
| 1779 | /** |
|
| 1780 | * Selects a different database than the one specified on construction. |
|