/** * Retorna uma string de ids separados por ', ' dos registros * * @param integer $idcomponente * @param integer $idstart * @param boolean $filhas * @param string [categorias | tags] * @return string */ function busca_registros_relacionados($idcomponente, $idstart = 0, $filhas = true, $tabela = 'categorias') { $ids = eHelper::busca_categorias_tags($idcomponente, $idstart, $filhas, $tabela); $ids = eUtil::joinCampo($ids); if ($tabela == 'categorias') { $tabela = ECOMP_TABLE_CADASTROS_CATEGORIAS; $campo = 'idcategoria'; } else { $tabela = ECOMP_TABLE_CADASTROS_TAGS; $campo = 'tdtag'; } $t = new JCRUD($tabela); $c = $t->busca("WHERE idcomponente = '{$idcomponente}' AND {$campo} IN ({$ids})"); $r = count($c) ? eUtil::joinCampo($c, 'idcadastro') : ''; return $r; }