Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony:如何连接表?_Php_Sql_Join_Symfony1_Doctrine - Fatal编程技术网

Php Symfony:如何连接表?

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 =

我正在进行退出项目。我想在SQL查询中连接两个表

$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();
参考: