function taxonomy_edge_get_top_tids in Taxonomy Edge 8
Same name and namespace in other branches
- 6 taxonomy_edge.module \taxonomy_edge_get_top_tids()
- 7 taxonomy_edge.module \taxonomy_edge_get_top_tids()
Get top term ids.
Parameters
$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 771 - Selecting all children of a given taxonomy term can be a pain. This module makes it easier to do this, by maintaining a complete list of edges for each term using the adjecency matrix graph theory.
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);
}