function taxonomy_edge_get_parents in Taxonomy Edge 6
Same name and namespace in other branches
- 8 taxonomy_edge.module \taxonomy_edge_get_parents()
- 7.2 taxonomy_edge.module \taxonomy_edge_get_parents()
- 7 taxonomy_edge.module \taxonomy_edge_get_parents()
Get parent from edge list.
Parameters
$tid: term id to get parent from.
Return value
array array of term ids.
1 call to taxonomy_edge_get_parents()
File
- ./
taxonomy_edge.module, line 742 - 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_parents($tid) {
$result = db_query("SELECT e.distance, e.parent\n FROM {term_data} d\n INNER JOIN {term_edge} e ON e.parent = d.tid\n WHERE e.tid = %d\n AND e.tid > 0\n AND e.distance > 0\n ORDER BY e.distance\n ", $tid);
$parents = array();
while ($row = db_fetch_object($result)) {
$parents[$row->distance] = $row->parent;
}
return $parents;
}