-3

I need to convert this sql line to Dql.

SELECT * FROM agent JOIN maison ON agent.id = maison.id_agent WHERE maison.id = 2
lurker
  • 56,987
  • 9
  • 69
  • 103
Nacer Naciri
  • 67
  • 2
  • 8
  • 2
    What have you tried so far? Do you have a specific question? Have you read any DQL documentation? What part of the conversion process are you stuck on? – lurker May 23 '16 at 18:05
  • I don't know how to use Join in Doctrine, I need to select the information from the two tables (entities) simultaneously. – Nacer Naciri May 23 '16 at 19:00
  • 1
    Please add your doctrine entities. It's hard to answer a question with only half the information. This is a very simple DQL join and it's documented very well here: http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html - suggest you read it. – Richard May 23 '16 at 20:02

1 Answers1

1
$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/

abhinand
  • 554
  • 5
  • 10