Reputation: 238
I have this code below and what i want is when one of the item is used after the loop i want to delete this item from the database....
$query = db_select('watchdog', 'th')
->extend('PagerDefault')
->orderBy('wid')
->fields('th', array('variables', 'type', 'severity', 'message', 'wid'))
->limit(2000);
// Fetch the result set.
$result = $query -> execute();
// Loop through each item and add to $row.
foreach ($result as $row) {
blablablabla($row);
}
Upvotes: 0
Views: 31
Reputation: 7124
https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_delete/7
You should Google a bit before asking those basic questions. Drupal at least has a bunch of examples, tutorials...
$nid = 5;
$num_deleted = db_delete('node')
->condition('nid', $nid)
->execute();
'node' is the table you are deleting record from and with condition method you can select exact row(s) to delete by setting some criteria. Here criteria is 'nid' field to be equal to $nid (5)....
So this example is deleting record from table 'node' where 'nid' is equal 5.
Upvotes: 1