Q:

Using Query Builder in Symfony 2

I am trying to use Query Builder in Symfony2 to get some records from a database. I run the normal query in SQL and it returns the correct results. The query is 
SELECT pg.name, pg.description
FROM pm_patentgroups pg
LEFT JOIN pm_portfolios pp ON pp.id = pg.portfolio_id

I want to use the exact query using Doctorine query builder in Symfony2. What I have tried so far is 
 $repository = $this->getDoctrine()
        ->getRepository('MunichInnovationGroupBundle:PmPatentgroups');
        $query = $repository->createQueryBuilder('pg')
        ->from('pm_patentgroups', 'pg')
        ->leftJoin('pg','pm_portfolios','pp','pp.id = pg.portfolio_id')
        ->getQuery();
        $portfolio_groups = $query->getResult();

but its giving me the following error:

Warning: Missing argument 1 for Doctrine\ORM\EntityRepository::createQueryBuilder()

I am new to Symfony2 and Doctorine. Can you please tell me what is going wrong here?
Thanks

A:

You are missing the alias when using createQueryBuilder.  Since you have the repository you can drop the from portion and just use
$query = $repository->createQueryBuilder('pg')

