Doctrine 2 request missing part of internal join

I am using Doctrine 2 to try to execute a query with an internal join. I have a site object and a page object. Each site can have many pages, and each page can belong to only one site. I have a foreign key site_id in the rows of the table of my pages. In the My Site object, I created the OneToMany association, where the target is my Page object, and mappedBy is the Site.

/**
 * @var \Doctrine\Common\Collections\ArrayCollection
 * @OneToMany(targetEntity="Page", mappedBy="Site", cascade={"persist", "remove"})
 */
private $pages;

In my page entity, I have the ManyToOne association where the target is set to the site.

/**
 * @var App\Entity\Site
 * @ManyToOne(targetEntity="Site")
 */
private $site;

Here is my builder request where I pass a specific site id:

$qb = $this->_em->createQueryBuilder();
$qb->select('s')
    ->from('App\Entity\Site', 's')
    ->innerJoin('s.pages', 'p')
    ->where('s.id = :id')
    ->setParameter('id', $id);

and here is the real SQL that I am returning:

SELECT s0_.id AS id0, s0_.domain AS domain1 FROM sites s0_ INNER JOIN  WHERE s0_.id = ?

, INNER JOIN? - Doctrine 2?

+3
2

. mappedBy. "", "".

0

Doctrine :

$qb->select('s', 'p')
   ->form(...)
   ->join(...) 
+3

All Articles