You are here

function apachesolr_get_parent_terms in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 apachesolr_search.module \apachesolr_get_parent_terms()
  2. 6 apachesolr_search.module \apachesolr_get_parent_terms()
1 call to apachesolr_get_parent_terms()
apachesolr_search_currentsearch_block in ./apachesolr_search.module
Return the contents of the "Current search" block.

File

./apachesolr_search.module, line 1576
Provides a content search implementation for node content for use with the Apache Solr search application.

Code

function apachesolr_get_parent_terms($tids) {

  // Find the starting tid terms and then all their parents.
  $parent_terms = array();
  $new_tids = $tids;
  do {
    $result = db_query(db_rewrite_sql("SELECT t.tid, t.parent FROM {term_hierarchy} t WHERE t.tid IN (" . db_placeholders($new_tids) . ")", 't', 'tid'), $new_tids);
    $new_tids = array();
    while ($term = db_fetch_object($result)) {
      $parent_terms[$term->tid] = $term;
      if ($term->parent > 0) {
        $new_tids[] = $term->parent;
      }
    }
  } while ($new_tids);
  return $parent_terms;
}