src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php
private function findCategoriesWithoutParents()
    {
        // get categories that have no parent but depth > 0
        $qb = $this->categoryRepository->createQueryBuilder('c2')
            ->select('count(c2.id)')
            ->leftJoin('c2.parent', 'c1')
            ->where('c2.depth <> 0 AND c2.parent IS NULL');

        return $qb->getQuery()->getSingleScalarResult();
    }
private function findCategoriesWithoutParents()
    {
        // get categories that have no parent but depth > 0
        $qb = $this->categoryRepository->createQueryBuilder('c2')
            ->select('count(c2.id)')
            ->leftJoin('c2.parent', 'c1')
            ->where('c2.depth <> 0 AND c2.parent IS NULL');

        return $qb->getQuery()->getSingleScalarResult();
    }
private function findCategoriesWithoutParents ( ) { // get categories that have no parent but depth > 0 $ qb = $ this -> categoryRepository -> createQueryBuilder ( 'c2' ) -> select ( 'count(c2.id)' ) -> leftJoin ( 'c2.parent' , 'c1' ) -> where ( 'c2.depth <> 0 AND c2.parent IS NULL' ) ; return $ qb -> getQuery ( ) -> getSingleScalarResult ( ) ; }
Find number of categories that have no parent but depth > 0.

@return int Number of categories without a parent
Find number of categories that have no parent but depth > 0 .