taxonomy_node_get_terms_by_vocabulary

Versions
4.6 – 5
taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid')
6
taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid')

Find all terms associated with the given node, within one vocabulary.

Code

modules/taxonomy/taxonomy.module, line 765

<?php
function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid') {
  $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight', 't', 'tid'), $vid, $nid);
  $terms = array();
  while ($term = db_fetch_object($result)) {
    $terms[$term->$key] = $term;
  }
  return $terms;
}
?>
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.