Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -544,6 +544,35 @@ |
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
| 548 | + * DELETE where the condition is a join |
| 549 | + * |
| 550 | + * @param $delTable String: The table to delete from. |
| 551 | + * @param $joinTable String: The other table. |
| 552 | + * @param $delVar String: The variable to join on, in the first table. |
| 553 | + * @param $joinVar String: The variable to join on, in the second table. |
| 554 | + * @param $conds Array: Condition array of field names mapped to variables, ANDed together in the WHERE clause |
| 555 | + * @param $fname String: Calling function name (use __METHOD__) for logs/profiling |
| 556 | + */ |
| 557 | + public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, |
| 558 | + $fname = 'DatabaseSqlite::deleteJoin' ) |
| 559 | + { |
| 560 | + if ( !$conds ) { |
| 561 | + throw new DBUnexpectedError( $this, |
| 562 | + 'DatabaseSqlite::deleteJoin() called with empty $conds' ); |
| 563 | + } |
| 564 | + |
| 565 | + $delTable = $this->tableName( $delTable ); |
| 566 | + $joinTable = $this->tableName( $joinTable ); |
| 567 | + $sql = "DELETE FROM $delTable WHERE $delVar IN (SELECT $joinVar FROM $joinTable"; |
| 568 | + if ( $conds != '*' ) { |
| 569 | + $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); |
| 570 | + } |
| 571 | + $sql .= ')'; |
| 572 | + |
| 573 | + $this->query( $sql, $fname ); |
| 574 | + } |
| 575 | + |
| 576 | + /** |
548 | 577 | * Returns the size of a text field, or -1 for "unlimited" |
549 | 578 | * In SQLite this is SQLITE_MAX_LENGTH, by default 1GB. No way to query it though. |
550 | 579 | * |