学说Querybuilder ORDER BY子句不在SELECT列表中 [英] Doctrine Querybuilder ORDER BY clause is not in SELECT list
问题描述
我有以下查询生成器:
$queryBuilder = $this
->createQueryBuilder('recipient')
->leftJoin('recipient.message', 'message')
->orderBy('message.dateSent', 'DESC');
这一直很好:)-但是升级到Mysql 5.7
之后,我开始到处都出现此错误:
This has been working fine :) - but since upgrading to Mysql 5.7
I have started getting this error everywhere:
SQLSTATE [HY000]:
一般错误:3065
ORDER BY
子句的表达式#1不在SELECT
列表中,引用的列'dctrn_result.date_sent_5'
不在SELECT
列表中;
这与DISTINCT
SQLSTATE[HY000]:
General error: 3065
Expression #1 ofORDER BY
clause is not inSELECT
list, references column'dctrn_result.date_sent_5'
which is not inSELECT
list;
this is incompatible withDISTINCT
我已经在大多数使用DBAL
层的地方解决了此问题,只需将该项添加到选择列表中,但是我不知道如何使用此特定的queryBuilder
来做到这一点.
I have solved this in most places where I am using the DBAL
layer by just add the item to the select list, but I can't figure out how to do that with this particular queryBuilder
.
推荐答案
您必须通过添加以下行来编辑/etc/mysql/mysql.cnf
:
You have to edit the /etc/mysql/mysql.cnf
by adding these lines:
[mysqld]
sql-mode=""
别忘了重启服务mysql:
Don't forget to restart the service mysql:
sudo service mysql restart
有关信息,我正在使用Ubuntu 16.04 LTS.
For info, I am using Ubuntu 16.04 LTS.
这篇关于学说Querybuilder ORDER BY子句不在SELECT列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!