本文介绍了学说Querybuilder ORDER BY子句不在SELECT列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询生成器:

$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:

我已经在大多数使用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列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 03:19