Created
June 23, 2010 11:42
-
-
Save zerolab/449820 to your computer and use it in GitHub Desktop.
Mass-deletion of Drupal nodetypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mass delete nodes of $nodetype | |
* put the file in the Drupal root and adjust $nodetype and $limit as you like | |
*/ | |
error_reporting(E_ALL); | |
require_once './includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
$nodetype = "INSERT_NODETYPE_HERE"; | |
$limit = 100; | |
$results = db_query("SELECT nid FROM {node} WHERE type='%s' LIMIT %d", $nodetype, $limit); | |
$count = 0; | |
while ($result = db_fetch_object($results)) { | |
node_delete($result->nid); | |
print 'Deleted node: ' . $result->nid . '<br />'; | |
$count++; | |
} | |
print "Total deleted: $count"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment