Php Symfony:如何连接表?
我正在进行退出项目。我想在SQL查询中连接两个表Php Symfony:如何连接表?,php,sql,join,symfony1,doctrine,Php,Sql,Join,Symfony1,Doctrine,我正在进行退出项目。我想在SQL查询中连接两个表 $this->chapterPages = Doctrine_Query::create() ->from( 'Page' ) ->leftJoin('PageAnchor pa ON pa.page_id = Page.sortorder') ->where( 'Page.chapter_id =
$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();
但我得到了以下错误:
查询中别名为“pa”的“PageAnchor”不引用
与之相关的父组件,请参考:example.com/abc/abc
有什么想法吗?试试这个:
$this->chapterPages = Doctrine_Query::create()
->from( 'Page p' )
->leftJoin('p.PageAnchor pa ON pa.page_id = Page.sortorder')
->where( 'Page.chapter_id = ?', $this->chapterId )
->execute();
参考: