taxonomy_get_children

  1. drupal
    1. 4.7
    2. 5 taxonomy.module
    3. 6 taxonomy.module
    4. 7 taxonomy.module
Versions
4.7 – 6 taxonomy_get_children($tid, $vid = 0, $key = 'tid')
7 taxonomy_get_children($tid, $vid = 0)

Find all children of a term ID.

Code

modules/taxonomy.module, line 848

<?php
function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
  if ($vid) {
    $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE t.vid = %d AND h.parent = %d ORDER BY weight, name', 't', 'tid'), $vid, $tid);
  }
  else {
    $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), $tid);
  }
  $children = array();
  while ($term = db_fetch_object($result)) {
    $children[$term->$key] = $term;
  }
  return $children;
}
?>