You are here

function taxonomy_get_related in Drupal 4

Same name and namespace in other branches
  1. 5 modules/taxonomy/taxonomy.module \taxonomy_get_related()
  2. 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.module

File

modules/taxonomy.module, line 797
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();
  }
}