You are here

function taxonomy_edge_get_parents in Taxonomy Edge 8

Same name and namespace in other branches
  1. 6 taxonomy_edge.module \taxonomy_edge_get_parents()
  2. 7.2 taxonomy_edge.module \taxonomy_edge_get_parents()
  3. 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()
TaxonomyEdgeTreeTestCase::testParents in tests/tree.test

File

./taxonomy_edge.module, line 751
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) {
  return db_query("\n    SELECT e.distance, e.parent\n    FROM {taxonomy_term_data} d\n    INNER JOIN {taxonomy_term_edge} e ON e.parent = d.tid\n    WHERE e.tid = :tid\n    AND e.tid > 0\n    AND e.distance > 0\n    ORDER BY e.distance\n  ", array(
    ':tid' => $tid,
  ))
    ->fetchAllKeyed();
}