taxonomy_vocabulary_delete

Versions
7
taxonomy_vocabulary_delete($vid)

Delete a vocabulary.

Parameters

$vid A vocabulary ID.

Return value

Constant indicating items were deleted.

Code

modules/taxonomy/taxonomy.module, line 367

<?php
function taxonomy_vocabulary_delete($vid) {
  $vocabulary = (array) taxonomy_vocabulary_load($vid);

  db_delete('taxonomy_vocabulary')
    ->condition('vid', $vid)
    ->execute();
  $result = db_query('SELECT tid FROM {taxonomy_term_data} WHERE vid = :vid', array(':vid' => $vid))->fetchCol();
  foreach ($result as $tid) {
    taxonomy_term_delete($tid);
  }

  field_attach_delete_bundle('taxonomy_term', $vocabulary['machine_name']);
  module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);

  cache_clear_all();
  entity_get_controller('taxonomy_vocabulary')->resetCache();

  return SAVED_DELETED;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.