DDC-201: Parent child association mapping and querying #251

Closed
opened 2026-01-22 12:32:15 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 8, 2009).

Jira issue originally created by user thecelavi:

This function:

public function &getPageTreePortion($dirId = null) {

        $qb = $this->em->createQueryBuilder();
        if (is_null($dirId)) {
            $qb->select('DP')
                    ->from('Pleomorph\Entities\Core\Domain\PageDirectory', 'DP')
                    ->where('DP.parentDirectory.id IS NULL');
        } else {
            $qb->select('DP')
                    ->from('Pleomorph\Entities\Core\Domain\PageDirectory', 'DP')
                    ->where('DP.parentDirectory.id = ?1');
            $qb->setParameter(1, $dirId);
        }
        $dirs = $qb->getQuery()->getResult();
        return $dirs;

    }

Results to qry:

SELECT p0*.id AS id0, p0_.title AS title1, p0_.position AS position2, p0_.id_language AS id_language3, p0_.default_page_id AS default_page_id4, p0_.parent_id AS parent_id5 FROM page_directory p0_ WHERE p0*.id IS NULL // or some value

it should be:

SELECT p0*.id AS id0, p0_.title AS title1, p0_.position AS position2, p0_.id_language AS id_language3, p0_.default_page_id AS default_page_id4, p0_.parent_id AS parent_id5 FROM page_directory p0_ WHERE p0_.parent*id IS NULL  // or some value```
Originally created by @doctrinebot on GitHub (Dec 8, 2009). Jira issue originally created by user thecelavi: This function: ``` public function &getPageTreePortion($dirId = null) { $qb = $this->em->createQueryBuilder(); if (is_null($dirId)) { $qb->select('DP') ->from('Pleomorph\Entities\Core\Domain\PageDirectory', 'DP') ->where('DP.parentDirectory.id IS NULL'); } else { $qb->select('DP') ->from('Pleomorph\Entities\Core\Domain\PageDirectory', 'DP') ->where('DP.parentDirectory.id = ?1'); $qb->setParameter(1, $dirId); } $dirs = $qb->getQuery()->getResult(); return $dirs; } ``` Results to qry: ``` SELECT p0*.id AS id0, p0_.title AS title1, p0_.position AS position2, p0_.id_language AS id_language3, p0_.default_page_id AS default_page_id4, p0_.parent_id AS parent_id5 FROM page_directory p0_ WHERE p0*.id IS NULL // or some value ``` it should be: `````` SELECT p0*.id AS id0, p0_.title AS title1, p0_.position AS position2, p0_.id_language AS id_language3, p0_.default_page_id AS default_page_id4, p0_.parent_id AS parent_id5 FROM page_directory p0_ WHERE p0_.parent*id IS NULL // or some value``` ``````
admin added the Bug label 2026-01-22 12:32:15 +01:00
admin closed this issue 2026-01-22 12:32:15 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 9, 2009):

Comment created by romanb:

You have to use the following for now:

select pd from Pleomorph\Entities\Core\Domain\PageDirectory pd left join pd.parentDirectory pdir where pdir.id IS NULL

See also: DDC-189

@doctrinebot commented on GitHub (Dec 9, 2009): Comment created by romanb: You have to use the following for now: ``` select pd from Pleomorph\Entities\Core\Domain\PageDirectory pd left join pd.parentDirectory pdir where pdir.id IS NULL ``` See also: [DDC-189](http://www.doctrine-project.org/jira/browse/DDC-189)
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Comment created by @beberlei:

This is fixed now

@doctrinebot commented on GitHub (Feb 26, 2010): Comment created by @beberlei: This is fixed now
Author
Owner

@doctrinebot commented on GitHub (Feb 26, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 26, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/650ba0ca151fa5e96ae3

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/650ba0ca151fa5e96ae3 - [10220_PageDirectory.php](https://gist.github.com/650ba0ca151fa5e96ae3#file-10220_PageDirectory-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#251