Return to Snippet

Revision: 24996
at March 17, 2010 14:00 by unravelme1


Initial Code
<?php
$type = 'YOUR CONTENT TYPE';
$aquery = db_query('SELECT n.nid FROM {node} n WHERE n.type = "%s"', $type);
if(user_access('administer nodes')) {
    set_time_limit(0);
    $count = 0;
    while ($n = db_fetch_object($aquery)) {
       node_delete($n->nid);
       echo $n->nid . 'deleted.';
       $count++;
    }
    echo $count . 'nodes deleted';
} 
else {
  echo "No " . $type . " nodes found or you do not have permission to modify nodes.";
}
?>

Initial URL
http://drupal.org/node/92861

Initial Description

                                

Initial Title
Delete all nodes by content type

Initial Tags
drupal

Initial Language
PHP