分类页面属性修改过后,不能访问产品分类页面

bug问题 · Ngeora · 于 8天前 发布 · 40 次阅读

修改了 分类页面-规格产品只显示一个sku 为yes 导致分类页面异常

Database Exception – yii\db\Exception
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'fecshop.product_flat.sku' 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 COUNT(*) FROM (SELECT `sku`, `spu`, `name`, `image`, `price`, `special_price`, `special_from`, `special_to`, `url_key`, `score`, `reviw_rate_star_average`, `review_count`, `favorite_count`, `created_at`, `qty`, `final_price` FROM `product_flat` WHERE (`id` IN ('43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54')) AND (`status`=1) GROUP BY `spu` ORDER BY `score` DESC) `c`
Error Info: Array
(
    [0] => 42000
    [1] => 1055
    [2] => Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'fecshop.product_flat.sku' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
)

Caused by: PDOException
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'fecshop.product_flat.sku' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
in /www/web/fecshop/vendor/yiisoft/yii2/db/Command.php at line 1290

本文由 Ngeora 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。

共收到 3 条回复 问题提问
Fecmall#18天前 0 个赞

mysql 5.7版本把?

参考帖子解决:http://www.fecmall.com/topic/2243

Ngeora#27天前 0 个赞

@Fecmall [#1楼](#comment1) 是的 最后问题解决了,这里贴上解决方法

  • 修改后台配置中的多个sku合并成一个spu(会出现Mysql错误,需要更改(common/config/main-local.php文件) 加入on afterOpen (我没有重启mysql服务该配置就自动生效了,刷新网页就行) `

    // Mysql部分的配置
         'db' => [
             'class' => 'yii\db\Connection',
             'dsn' => 'mysql:host=127.0.0.1;dbname=fecmall',
             'username' => 'root',
             'password' => '123456',
             'charset' => 'utf8',
             'on afterOpen' => function ($event) {
                 $event->sender->createCommand("set session sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'")->execute();
             }
    
          ],
    
Fecmall#36天前 0 个赞

好的

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics