Skip to content

Instantly share code, notes, and snippets.

@mecmartini
Created May 29, 2021 14:24
Show Gist options
  • Save mecmartini/05e8e1f9cadf51ff3715a7cf81557904 to your computer and use it in GitHub Desktop.
Save mecmartini/05e8e1f9cadf51ff3715a7cf81557904 to your computer and use it in GitHub Desktop.
Drupal 7 - Programmatically delete nodes
<?php
$results = db_select('node', 'n')
->fields('n', ['nid'])
->condition('type', 'organisation')
->condition('nid', 35401, '<>')
->execute()
->fetchAll();
dpm($results);
foreach ($results as $node) {
node_delete($node->nid);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment