| @@ 1603-1629 (lines=27) @@ | ||
| 1600 | * |
|
| 1601 | * @throws QueryException |
|
| 1602 | */ |
|
| 1603 | public function select($table, $where = '1=1', $databaseName = null) |
|
| 1604 | { |
|
| 1605 | // init |
|
| 1606 | $table = trim($table); |
|
| 1607 | ||
| 1608 | if ($table === '') { |
|
| 1609 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 1610 | ||
| 1611 | return false; |
|
| 1612 | } |
|
| 1613 | ||
| 1614 | if (is_string($where)) { |
|
| 1615 | $WHERE = $this->escape($where, false); |
|
| 1616 | } elseif (is_array($where)) { |
|
| 1617 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1618 | } else { |
|
| 1619 | $WHERE = ''; |
|
| 1620 | } |
|
| 1621 | ||
| 1622 | if ($databaseName) { |
|
| 1623 | $databaseName = $this->quote_string(trim($databaseName)) . '.'; |
|
| 1624 | } |
|
| 1625 | ||
| 1626 | $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 1627 | ||
| 1628 | return $this->query($sql); |
|
| 1629 | } |
|
| 1630 | ||
| 1631 | /** |
|
| 1632 | * Set the current charset. |
|
| @@ 617-643 (lines=27) @@ | ||
| 614 | * |
|
| 615 | * * @throws QueryException |
|
| 616 | */ |
|
| 617 | public function delete($table, $where, $databaseName = null) |
|
| 618 | { |
|
| 619 | // init |
|
| 620 | $table = trim($table); |
|
| 621 | ||
| 622 | if ($table === '') { |
|
| 623 | $this->_debug->displayError('Invalid table name, table name in empty.', false); |
|
| 624 | ||
| 625 | return false; |
|
| 626 | } |
|
| 627 | ||
| 628 | if (is_string($where)) { |
|
| 629 | $WHERE = $this->escape($where, false); |
|
| 630 | } elseif (is_array($where)) { |
|
| 631 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 632 | } else { |
|
| 633 | $WHERE = ''; |
|
| 634 | } |
|
| 635 | ||
| 636 | if ($databaseName) { |
|
| 637 | $databaseName = $this->quote_string(trim($databaseName)) . '.'; |
|
| 638 | } |
|
| 639 | ||
| 640 | $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 641 | ||
| 642 | return $this->query($sql); |
|
| 643 | } |
|
| 644 | ||
| 645 | /** |
|
| 646 | * Ends a transaction and commits if no errors, then ends autocommit. |
|