Same name and namespace in other branches
  1. 4.6.x modules/taxonomy.module \taxonomy_get_related()
  2. 4.7.x modules/taxonomy.module \taxonomy_get_related()
  3. 5.x 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.admin.inc
Form function for the term edit form.

File

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