You are here

function taxonomy_edge_get_parents in Taxonomy Edge 7.2

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 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.

File

./taxonomy_edge.module, line 834
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 d.*\n    FROM {taxonomy_term_edge} ce\n    INNER JOIN {taxonomy_term_edge_path} cp ON ce.pid = cp.pid AND ce.distance > 0\n    INNER JOIN {taxonomy_term_edge_path} pp ON pp.pid = ce.parent\n    INNER JOIN {taxonomy_term_data} d ON d.tid = pp.tid\n    WHERE cp.tid = :tid AND pp.tid > 0\n    ORDER BY ce.distance\n  ", array(
    ':tid' => $tid,
  ))
    ->fetchAll(PDO::FETCH_OBJ);
}