| @@ 1473-1499 (lines=27) @@ | ||
| 1470 | * |
|
| 1471 | * @return false|int false on error |
|
| 1472 | */ |
|
| 1473 | public function delete($table, $where, $database = null) |
|
| 1474 | { |
|
| 1475 | ||
| 1476 | $table = trim($table); |
|
| 1477 | ||
| 1478 | if ($table === '') { |
|
| 1479 | $this->_debug->displayError('invalid table name'); |
|
| 1480 | ||
| 1481 | return false; |
|
| 1482 | } |
|
| 1483 | ||
| 1484 | if (is_string($where)) { |
|
| 1485 | $WHERE = $this->escape($where, false); |
|
| 1486 | } elseif (is_array($where)) { |
|
| 1487 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1488 | } else { |
|
| 1489 | $WHERE = ''; |
|
| 1490 | } |
|
| 1491 | ||
| 1492 | if ($database) { |
|
| 1493 | $database = $this->quote_string(trim($database)) . '.'; |
|
| 1494 | } |
|
| 1495 | ||
| 1496 | $sql = 'DELETE FROM ' . $database . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 1497 | ||
| 1498 | return $this->query($sql); |
|
| 1499 | } |
|
| 1500 | ||
| 1501 | /** |
|
| 1502 | * Execute a "select"-query. |
|
| @@ 1510-1534 (lines=25) @@ | ||
| 1507 | * |
|
| 1508 | * @return false|Result false on error |
|
| 1509 | */ |
|
| 1510 | public function select($table, $where = '1=1', $database = null) |
|
| 1511 | { |
|
| 1512 | ||
| 1513 | if ($table === '') { |
|
| 1514 | $this->_debug->displayError('invalid table name'); |
|
| 1515 | ||
| 1516 | return false; |
|
| 1517 | } |
|
| 1518 | ||
| 1519 | if (is_string($where)) { |
|
| 1520 | $WHERE = $this->escape($where, false); |
|
| 1521 | } elseif (is_array($where)) { |
|
| 1522 | $WHERE = $this->_parseArrayPair($where, 'AND'); |
|
| 1523 | } else { |
|
| 1524 | $WHERE = ''; |
|
| 1525 | } |
|
| 1526 | ||
| 1527 | if ($database) { |
|
| 1528 | $database = $this->quote_string(trim($database)) . '.'; |
|
| 1529 | } |
|
| 1530 | ||
| 1531 | $sql = 'SELECT * FROM ' . $database . $this->quote_string($table) . " WHERE ($WHERE);"; |
|
| 1532 | ||
| 1533 | return $this->query($sql); |
|
| 1534 | } |
|
| 1535 | ||
| 1536 | /** |
|
| 1537 | * Get the last sql-error. |
|