Doctrine Querybuilder ORDER BY clause is not in SELECT list

后端 未结 5 1517
清歌不尽
清歌不尽 2021-02-08 08:29

I have the following query builder:

$queryBuilder = $this
    ->createQueryBuilder(\'recipient\')
    ->leftJoin(\'recipient.message\', \'message\')
    -&         


        
5条回答
  •  半阙折子戏
    2021-02-08 09:15

    When using QueryBuilder, joined tables are not added to the select list automatically. You can call addSelect(TABLE_ALIAS) to get rid of the error.

    $queryBuilder = $this
        ->createQueryBuilder('recipient')
        ->leftJoin('recipient.message', 'message')
        ->addSelect('message') //THIS LINE
        ->orderBy('message.dateSent', 'DESC');
    

提交回复
热议问题