Posted By

unravelme1 on 03/17/10


Tagged

drupal


Versions (?)

Delete all nodes by content type


 / Published in: PHP
 

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

  1. <?php
  2. $type = 'YOUR CONTENT TYPE';
  3. $aquery = db_query('SELECT n.nid FROM {node} n WHERE n.type = "%s"', $type);
  4. if(user_access('administer nodes')) {
  5. $count = 0;
  6. while ($n = db_fetch_object($aquery)) {
  7. node_delete($n->nid);
  8. echo $n->nid . 'deleted.';
  9. $count++;
  10. }
  11. echo $count . 'nodes deleted';
  12. }
  13. else {
  14. echo "No " . $type . " nodes found or you do not have permission to modify nodes.";
  15. }
  16. ?>

Report this snippet  

You need to login to post a comment.