public function get_parents($id = 0, $without_main_parrent = false, $data_type = 'category')
{
if (intval($id) == 0) {
return false;
}
$table = $this->tables['categories'];
$ids = array();
$data = array();
if (isset($without_main_parrent) and $without_main_parrent == true) {
$with_main_parrent_q = ' and parent_id<>0 ';
} else {
$with_main_parrent_q = false;
}
$id = intval($id);
$q = " select id, parent_id from {$table} where id = {$id} and data_type='{$data_type}' " . $with_main_parrent_q;
$params = array();
$params['table'] = $table;
$params['id'] = $id;
$params['data_type'] = $data_type;
if (isset($without_main_parrent) and $without_main_parrent == true) {
$params['parent_id'] = '[neq]0';
}
$taxonomies = $this->app->database_manager->get($params);
// $taxonomies = $this->app->database_manager->query($q, $cache_id = __FUNCTION__ . crc32($q), $cache_group = 'categories/' . $id);
if (!empty($taxonomies)) {
foreach ($taxonomies as $item) {
if (intval($item['id']) != 0) {
$ids[] = $item['parent_id'];
}
if ($item['parent_id'] != $item['id']) {
$next = $this->get_parents($item['parent_id'], $without_main_parrent);
if (!empty($next)) {
foreach ($next as $n) {
if ($n != '') {
$ids[] = $n;
}
}
}
}
}
}
if (!empty($ids)) {
$ids = array_unique($ids);
return $ids;
} else {
return false;
}
}