Giter Club home page Giter Club logo

Comments (6)

baqianxin avatar baqianxin commented on July 19, 2024

Database Exception – yii\db\Exception

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'yii2admin.yii2_menu.sort' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
The SQL being executed was: SELECT group FROM yii2_menu WHERE (pid='68') AND (hide=0) GROUP BY group ORDER BY sort
Error Info: Array
(
[0] => 42000
[1] => 1055
[2] => Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'yii2admin.yii2_menu.sort' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
)

from yii2admin.

e282486518 avatar e282486518 commented on July 19, 2024

是安装后就出现这个错误,还是修改了某些内容后导致的这个错误?可否重现?

from yii2admin.

baqianxin avatar baqianxin commented on July 19, 2024

可以重现,是mysql查询语句的问题,Group 与 Order 共同存在时,有的查询模式需要Group强制包含Order表达式所含字段,加上即可

from yii2admin.

e282486518 avatar e282486518 commented on July 19, 2024

这条sql语句确实写的不标准,only_full_group_by模式下会有sort不明确导致的问题,谢谢指正。

不过我更倾向于这个,mysql5.5不知道怎么开启这个模式,没有测试,不知道对不对。

$groups = static::find()->select(['group','min(sort) as sort']) ->where(['pid'=>$item['id'], 'hide'=>0]) ->groupBy(['sort','group'])->orderBy('sortASC')->asArray()->column();

from yii2admin.

e282486518 avatar e282486518 commented on July 19, 2024

$groups = static::find()->select(['group','min(sort) as sort']) ->where(['pid'=>$item['id'], 'hide'=>0]) ->groupBy(['group'])->orderBy('sortASC')->asArray()->column();

from yii2admin.

baqianxin avatar baqianxin commented on July 19, 2024

多向你学习

from yii2admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.