Created
August 6, 2015 15:46
-
-
Save tommy-thomas/fb074ef09ac2f1b9d69e to your computer and use it in GitHub Desktop.
Delete nodes by type in /devel/php
This file contains hidden or 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
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