Skip to content

Instantly share code, notes, and snippets.

@aschanMarcus
Created March 28, 2014 09:02
Show Gist options
  • Select an option

  • Save aschanMarcus/9828451 to your computer and use it in GitHub Desktop.

Select an option

Save aschanMarcus/9828451 to your computer and use it in GitHub Desktop.
Delete all nodes of certain type
$results = db_select('node', 'n')
->fields('n', array('nid'))
->condition('type', TYPE)
->execute();
foreach ($results as $result) {
$nids[] = $result->nid;
}
if (!empty($nids)) {
node_delete_multiple($nids);
drupal_set_message(t('Deleted %count nodes.', array('%count' => count($nids))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment