You are here

function taxonomy_term_depth_get_parent in Taxonomy Term Depth 7

Same name and namespace in other branches
  1. 8.2 taxonomy_term_depth.module \taxonomy_term_depth_get_parent()
  2. 8 taxonomy_term_depth.module \taxonomy_term_depth_get_parent()

Gets parent of the term

Parameters

$tid: Term tid to find its parent

2 calls to taxonomy_term_depth_get_parent()
taxonomy_term_depth_get_parents in ./taxonomy_term_depth.module
Get parents of the term.
_taxonomy_term_depth_get_nocache in ./taxonomy_term_depth.module
Calculates taxonomy term depth from database

File

./taxonomy_term_depth.module, line 102
Provides some custom functionality.

Code

function taxonomy_term_depth_get_parent($tid, $nocache = FALSE) {
  $cache =& drupal_static(__FUNCTION__, array());
  $cache_key = $tid;
  if (!isset($cache[$cache_key]) || $nocache) {
    $cache[$cache_key] = db_query("SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = :tid", array(
      ':tid' => $tid,
    ))
      ->fetchField();
  }
  return $cache[$cache_key];
}