public function DataHandler::delete in Data 7
Same name and namespace in other branches
- 8 includes/DataHandler.inc \DataHandler::delete()
- 6 includes/DataHandler.inc \DataHandler::delete()
Delete one or more records from the table.
Parameters
$clause: An array where the keys are columns in the data table and the values are the values to filter on. This array will be turned into the where clause of the delete query.
Example:
array( 'feed_nid' => 10, 'timestamp' => array( '<', 1255623780, ), );
File
- includes/
DataHandler.inc, line 145 - Definition of DataHandler class.
Class
- DataHandler
- Simple access methods to table data. Can be used on any table, not just Data managed tables.
Code
public function delete($clause) {
$query = db_delete($this->table);
// Add the clauses.
foreach ($clause as $column => $clause_data) {
if (is_array($clause_data)) {
list($operator, $value) = $clause_data;
}
else {
$operator = '=';
$value = $clause_data;
}
$query
->condition($column, $value, $operator);
}
// Invoke hook_data_table_delete_rows().
module_invoke_all('data_table_delete_rows', $this, $clause);
// Return the number of deleted rows.
return $query
->execute();
}