Created
          August 20, 2013 08:39 
        
      - 
      
 - 
        
Save jamesmorrish/6278797 to your computer and use it in GitHub Desktop.  
    Delete all nodes of type
  
        
  
    
      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
    
  
  
    
  | $node_type = 'product'; | |
| // Select the nodes that we want to delete. | |
| $result = db_select('node', 'n') | |
| ->fields('n', array('nid')) | |
| ->condition('type', $node_type, '=') | |
| ->range(0,5) | |
| ->execute(); | |
| $deleted_count = 0; | |
| foreach ($result as $record) { | |
| node_delete($record->nid); | |
| $deleted_count++; | |
| } | |
| // Simple debug message so we can see what had been deleted. | |
| echo "<!-- $deleted_count nodes have been deleted -->"; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment