2010
03.24

This function retrieves vocabulary names by their id.

getVocabularyNameByVID($vid)

1
2
3
4
5
6
7
8
9
10
11
function getVocabularyNameByVID($vid) {
  /* make sure vid is numeric */
  if(!is_numeric($vid)) return false;
 
  /* fetch name */
  $result = db_query("SELECT name FROM {vocabulary} WHERE vid = %d", $vid);
  $name = db_fetch_object($result)->name;
 
  /* return name or false if not found */
  return $name ? $name : false;
}

Usage

1
print getVocabularyNameByVID(1);

2 comments so far

Add Your Comment
  1. use function taxonomy_vocabulary_load() from taxonomy module instead.

  2. why not simply use the following ?
    taxonomy_vocabulary_load($vid)->name

*