I am working on exiting project. I want to join two tables in SQL query.
$this->chapterPages = Doctrine_Query::create()
->from( 'Page' )
->leftJoin('PageAnchor pa ON pa.page_id = Page.sortorder')
->where( 'Page.chapter_id = ?', $this->chapterId )
->execute();
$this->chapterPages = $this->chapterPages->toArray();
But I am getting following error:
“PageAnchor” with an alias of “pa” in your query does not reference
the parent component it is related to., referer: example.com/abc/abc
Any idea ?
Try this:
Reference:
http://www.doctrine-project.org/documentation/manual/1_2/ru/dql-doctrine-query-language:join-syntax