Search code examples
sqlsymfonydqldoctrine-query

Convert Sql to Dql


I need to convert this sql line to Dql.

SELECT * FROM agent JOIN maison ON agent.id = maison.id_agent WHERE maison.id = 2

Solution

  • $qb = $this->getEntityManager()->createQueryBuilder();
    
        return $qb->select('a')
                ->from('Your Bundle Agent', 'a')$criteria['company']))
                ->join('a. maison', 'm', 'WITH', 'a.id=m.id_maison')
                ->where('maison.id = 2')
                ->getQuery()
                ->getResult();
    

    try this link http://doctrine-orm.readthedocs.org/en/latest/