You are here

function taxonomy_edge_get_top_tids in Taxonomy Edge 7

Same name and namespace in other branches
  1. 8 taxonomy_edge.module \taxonomy_edge_get_top_tids()
  2. 6 taxonomy_edge.module \taxonomy_edge_get_top_tids()

Get top term ids.

Parameters

integer $tid: Term ID to get top term ID from.

Return value

array Top term IDs.

2 calls to taxonomy_edge_get_top_tids()
TaxonomyEdgeTreeTestCase::testParents in tests/tree.test
taxonomy_edge_get_top_tid in ./taxonomy_edge.module
Get top term id.

File

./taxonomy_edge.module, line 839
Optimization of taxonomy data model for SQL performance.

Code

function taxonomy_edge_get_top_tids($tid) {
  return db_query("SELECT DISTINCT e2.parent\n    FROM {taxonomy_term_edge} e\n    JOIN {taxonomy_term_edge} e2 ON e2.tid = e.tid AND e2.distance = e.distance - 1 AND e2.parent <> e.parent\n    WHERE e.tid = :tid\n    AND e.parent = 0\n    AND e.vid = e2.vid\n  ", array(
    ':tid' => $tid,
  ))
    ->fetchAllKeyed(0, 0);
}