/** * Busca o id da categoria/tag PAI * * @param integer $idcomponente * @param integer $idstart * @param boolean $tree * @param string [categorias | tags] * @return object/JCRUD */ function busca_categorias_tags_pai($idcomponente, $idstart = 0, $tabela = 'categorias') { $tb = $tabela == 'categorias' ? ECOMP_TABLE_CATEGORIAS : ECOMP_TABLE_TAGS; $t = new JCRUD($tb); $a = $t->busca("WHERE idcomponente = '{$idcomponente}' AND id = '{$idstart}'"); if ($a->idpai != 0) { $tt = $t->busca("WHERE idcomponente = '{$idcomponente}' AND idpai = '{$idstart}'"); foreach ($tt as $tr) { $a = eHelper::busca_categorias_tags_pai($idcomponente, $tr->id, $tabela); } } return $a->id; }