Skip to content

Instantly share code, notes, and snippets.

@tommy-thomas
Created August 6, 2015 15:46
Show Gist options
  • Save tommy-thomas/fb074ef09ac2f1b9d69e to your computer and use it in GitHub Desktop.
Save tommy-thomas/fb074ef09ac2f1b9d69e to your computer and use it in GitHub Desktop.
Delete nodes by type in /devel/php
ignore_user_abort(true);
ini_set('max_execution_time', 600);
set_time_limit(0);
$node_type = 'story';
//fetch the nodes we want to delete
$result = db_query('SELECT n.nid FROM {node} n WHERE n.type = :node_type', array(':node_type' => $node_type));
foreach( $result as $row ){
node_delete($row->nid);
$deleted_count+=1;
}
//simple debug message so we can see what had been deleted.
drupal_set_message("$deleted_count nodes have been deleted");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment