function taxonomy_get_related in Drupal 5
Same name and namespace in other branches
- 4 modules/taxonomy.module \taxonomy_get_related()
 - 6 modules/taxonomy/taxonomy.module \taxonomy_get_related()
 
Find all term objects related to a given term ID.
1 call to taxonomy_get_related()
- taxonomy_form_term in modules/
taxonomy/ taxonomy.module  
File
- modules/
taxonomy/ taxonomy.module, line 903  - Enables the organization of content into categories.
 
Code
function taxonomy_get_related($tid, $key = 'tid') {
  if ($tid) {
    $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
    $related = array();
    while ($term = db_fetch_object($result)) {
      $related[$term->{$key}] = $term;
    }
    return $related;
  }
  else {
    return array();
  }
}