_taxonomy_term_children

Versions
4.6 – 6
_taxonomy_term_children($tid)

Helper for taxonomy_term_count_nodes(). Used to find out which terms are children of a parent term.

Parameters

$tid The parent term's ID

Return value

array An array of term IDs representing the children of $tid. Results are statically cached.

Code

modules/taxonomy/taxonomy.module, line 1099

<?php
function _taxonomy_term_children($tid) {
  static $children;

  if (!isset($children)) {
    $result = db_query('SELECT tid, parent FROM {term_hierarchy}');
    while ($term = db_fetch_object($result)) {
      $children[$term->parent][] = $term->tid;
    }
  }
  return $children[$tid] ? $children[$tid] : array();
}
?>
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.