public function getParentByClassName($childUid, $classname)
    {
        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('j.parent_uid, c.classname')
                ->from('content_has_subcontent', 'j')
                ->from('content', 'c')
                ->andWhere('c.uid = j.parent_uid')
                ->andWhere('j.content_uid = :uid')
                ->setParameter('uid', $childUid);

        $result = $q->execute()->fetch();
        if (false !== $result) {
            if ($result['classname'] == $classname) {
                return $this->_em->find($classname, $result['parent_uid']);
            } else {
                $result = $this->getParentByClassName($result['parent_uid'], $classname);
            }
        } else {
            return;
        }

        return $result;
    }
public function getParentByClassName($childUid, $classname)
    {
        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('j.parent_uid, c.classname')
                ->from('content_has_subcontent', 'j')
                ->from('content', 'c')
                ->andWhere('c.uid = j.parent_uid')
                ->andWhere('j.content_uid = :uid')
                ->setParameter('uid', $childUid);

        $result = $q->execute()->fetch();
        if (false !== $result) {
            if ($result['classname'] == $classname) {
                return $this->_em->find($classname, $result['parent_uid']);
            } else {
                $result = $this->getParentByClassName($result['parent_uid'], $classname);
            }
        } else {
            return;
        }

        return $result;
    }
public function getParentByClassName ( $ childUid , $ classname ) { $ q = $ this -> _em -> getConnection ( ) -> createQueryBuilder ( ) -> select ( 'j.parent_uid, c.classname' ) -> from ( 'content_has_subcontent' , 'j' ) -> from ( 'content' , 'c' ) -> andWhere ( 'c.uid = j.parent_uid' ) -> andWhere ( 'j.content_uid = :uid' ) -> setParameter ( 'uid' , $ childUid ) ; $ result = $ q -> execute ( ) -> fetch ( ) ; if ( false !== $ result ) { if ( $ result [ 'classname' ] == $ classname ) { return $ this -> _em -> find ( $ classname , $ result [ 'parent_uid' ] ) ; } else { $ result = $ this -> getParentByClassName ( $ result [ 'parent_uid' ] , $ classname ) ; } } else { return ; } return $ result ; }
Returns an uid if parent with this classname found, false otherwise.

@param string $childUid
@param string $classname

@return mixed
Returns an uid if parent with this classname found false otherwise .