taxonomy_get_parents
modules/taxonomy/taxonomy.module, строка 921
- Версии
- 5 – 6
taxonomy_get_parents($tid, $key = 'tid')
Находит всех родителей данного идентификатора термина по его ID.
Код
<?php
function taxonomy_get_parents($tid, $key = 'tid') {
if ($tid) {
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);
$parents = array();
while ($parent = db_fetch_object($result)) {
$parents[$parent->$key] = $parent;
}
return $parents;
}
else {
return array();
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии