You are here

function taxonomy_edge_get_parents in Taxonomy Edge 7

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

Get parent from edge list.

Parameters

integer $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 818
Optimization of taxonomy data model for SQL performance.

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();
}