| 693 | * Delete rows in a table |
| 694 | * |
| 695 | * @since 2.7 |
| 696 | * |
| 697 | * @param string $table name |
| 698 | * @param array $where A named array of WHERE column => value pairs. |
| 699 | * @return mixed Results of $this->query() |
| 700 | */ |
| 701 | function delete($table, $where){ |
| 702 | return $this->query( " DELETE FROM $table WHERE " . $this->make_wheres($where)); |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * Create a where clause for use in sql queries. WARNING: Only works for ANDs at the moment |
| 707 | * |
| 708 | * @since 2.7 |
| 709 | * |
| 710 | * @param array $where A named array of WHERE column => value pairs. Multiple pairs will be joined by AND. |
| 711 | * @return string a WHERE clause for use in SQL statement |
| 712 | * */ |
| 713 | function make_wheres($where){ |
| 714 | $wheres = array(); |
| 715 | if (is_array( $where ) ) |
| 716 | foreach ( $where as $c => $v ) |
| 717 | $wheres[] = "$c = '" . $this->escape( $v ) ."'"; |
| 718 | else |
| 719 | return false; |
| 720 | |
| 721 | return implode( ' AND ',$wheres); |
| 722 | } |
| 723 | |
| 724 | /** |