Do you also use one Datawriter statement to delete multiple rows? I have a table:
$dw->delete("apple") is actually what I want. Is it possible with xf 1.2?id, fruit, country
1, apple, usa
2, apple, italy
3, banana, brazil
4, orange, spain
XenForo deletes its attachments as an example also in its Model:Deleting Rows from a Table
You can delete rows from a database table using the delete() method. This method takes one argument, which is an SQL expression that is used in a WHERE clause, as criteria for the rows to delete.
Example #18 Example of deleting rows from a Table
Since the table delete() method proxies to the database adapter delete() method, the argument can also be an array of SQL expressions. The expressions are combined as Boolean terms using an AND operator.
- $table = new Bugs();
- $where = $table->getAdapter()->quoteInto('bug_id = ?', 1235);
Note: The values and identifiers in the SQL expression are not quoted for you. If you have values or identifiers that require quoting, you are responsible for doing this. Use the quote(), quoteInto(), and quoteIdentifier() methods of the database adapter.
$db = $this->_getDb(); $db->delete('xf_attachment', 'attachment_id IN (' . $db->quote(array_keys($attachments)) . ')' );