Skip to content

Instantly share code, notes, and snippets.

@jonathanfranks
Last active August 29, 2015 14:17
Show Gist options
  • Save jonathanfranks/dbcfd1ccb444c7533368 to your computer and use it in GitHub Desktop.
Save jonathanfranks/dbcfd1ccb444c7533368 to your computer and use it in GitHub Desktop.
Delete all entities of a type
$entity_type = 'node';
$bundle = 'article';
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', $entity_type)
->entityCondition('bundle', $bundle);
$result = $query->execute();
if (isset($result[$entity_type])) {
$ids = array_keys($result[$entity_type]);
entity_delete_multiple($entity_type, $ids);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment