解决办法
打开mysql配置文件,在[mysqld]下添加如下一行:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
成功解决!
还以为是网站的代码问题, 惊讶到我了. 开源网站下载下来就报错 多不可思议. 终于是配置的问题!
加油
报错信息如下是其中一个界面的!
Database Exception – yii\db\Exception
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'dongpinpifa.b.brand_logo' 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(*) AS `count`, `g`.`brand`, `b`.`brand_logo` FROM `swd_goods` `g` LEFT JOIN `swd_goods_statistics` `gst` ON `g`.`goods_id` = `gst`.`goods_id` LEFT JOIN `swd_store` `s` ON `g`.`store_id` = `s`.`store_id` LEFT JOIN `swd_goods_pvs` `gp` ON `g`.`goods_id` = `gp`.`goods_id` LEFT JOIN `swd_brand` `b` ON `g`.`brand` = `b`.`brand_name` WHERE ((`g`.`if_show`=1) AND (`g`.`closed`=0) AND (`s`.`state`=1)) AND (`g`.`cate_id` IN (2571, '2581', '2580', '2579')) AND (`b`.`if_show`=1) GROUP BY `g`.`brand` ORDER BY `count` DESC
Error Info: Array
(
[0] => 42000
[1] => 1055
[2] => Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'dongpinpifa.b.brand_logo' 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 #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'dongpinpifa.b.brand_logo' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Command.php at line 1299
1. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Schema.phpat line 678
669670671672673674675676677678679680681682683684685686687
$exceptionClass = '\yii\db\Exception';
foreach ($this->exceptionMap as$error => $class) {
if (strpos($e->getMessage(), $error) !== false) {
$exceptionClass = $class;
}
}
$message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
$errorInfo = $einstanceof \PDOException ? $e->errorInfo : null;
returnnew$exceptionClass($message, $errorInfo, $e->getCode(), $e);
}
/**
* Returns a value indicating whether a SQL statement is for read purpose.
* @param string $sql the SQL statement
* @return bool whether a SQL statement is for read purpose.
*/publicfunctionisReadQuery($sql)
{
2. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Command.php at line 1304– yii\db\Schema::convertException(PDOException, 'SELECT count(*) AS `count`, `g`....')
3. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Command.php at line 1165– yii\db\Command::internalExecute('SELECT count(*) AS `count`, `g`....')
4. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Command.php at line 407– yii\db\Command::queryInternal('fetchAll', null)
5. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\Query.php at line 249– yii\db\Command::queryAll()
6. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\db\ActiveQuery.php at line 133– yii\db\Query::all(null)
7. in E:\WWW\dongpinpifa\frontend\models\SearchForm.php at line 109– yii\db\ActiveQuery::all()
103104105106107108109110111112113114115
} else$by_category[$group[0]] = ['cate_id' => $group[0], 'cate_name' => $group[1], 'count' => $val['count']];
}
}
$result['by_category'] = array_values($by_category);
// 按品牌统计$by_brand = $this->getConditions($post)->select('count(*) as count,g.brand,b.brand_logo')->joinWith('brand b', false)->andWhere(['b.if_show' => 1])->groupBy('g.brand')->orderBy(['count' => SORT_DESC])->asArray()->all();
$result['by_brand'] = $by_brand;
// 按价格统计$by_price = array();
$priceMin = $this->getConditions($post)->min('g.price');
$priceMax = min($this->getConditions($post)->max('g.price'), 10000);
8. in E:\WWW\dongpinpifa\frontend\controllers\SearchController.php at line 93– frontend\models\SearchForm::getSelectors(stdClass)
87888990919293949596979899
$this->params['recommend_goods'] = GoodsModel::find()->alias('g')->select('g.goods_id,g.goods_name,g.default_image,g.price,gst.sales')->joinWith('goodsStatistics gst', false)->limit(5)->orderBy(['gst.views' => SORT_DESC])->asArray()->all();
// 品牌旗舰店$this->params['flagstore'] = \common\models\FlagstoreModel::getFlagstore($post);
// 按分类/品牌/价格/属性/地区统计$this->params = array_merge($this->params, $model->getSelectors($post));
// 读取所有省份列表$this->params['provinces'] = $this->getProvinces($post);
// 排序$this->params['orders'] = $model->getOrders();
9. frontend\controllers\SearchController::actionIndex()
10. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\base\InlineAction.php at line 57– call_user_func_array([frontend\controllers\SearchController, 'actionIndex'], [])
11. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\base\Controller.php at line 181– yii\base\InlineAction::runWithParams(['cate_id' => '2571'])
12. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\base\Module.php at line 534– yii\base\Controller::runAction('index', ['cate_id' => '2571'])
13. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\web\Application.php at line 104– yii\base\Module::runAction('search/index', ['cate_id' => '2571'])
14. in E:\WWW\dongpinpifa\vendor\yiisoft\yii2\base\Application.php at line 392– yii\web\Application::handleRequest(yii\web\Request)
15. in E:\WWW\dongpinpifa\frontend\web\index.php at line 17– yii\base\Application::run()
11121314151617
require __DIR__ . '/../../common/config/main.php',
require __DIR__ . '/../../common/config/main-local.php',
require __DIR__ . '/../config/main.php',
require __DIR__ . '/../config/main-local.php'
);
(new yii\web\Application($config))->run();
$_GET = [
'cate_id' => '2571',
];
$_COOKIE = [
'_csrf' => '504189953fd20d89a5211031a059275a2bd45561be4210d722231043556a9c6da:2:{i:0;s:5:"_csrf";i:1;s:32:"XeuAm-dJr0gswx0JYrMt39JkwzTnTLM_";}',
'PHPSESSID' => 'os75srj9hpckvk1nkf3v3l0ea2',
'advanced-backend' => 'tlftcl39hvurkhqqn9f8ecjqfp',
'_csrf-backend' => 'ef0839b137b3666331914e4ad44b4f420de761165c128843a7c9ab08f77e5063a:2:{i:0;s:13:"_csrf-backend";i:1;s:32:"Q8Lf1A7oTo-pjj80LuZjvXvSzBXICEFj";}',
'goodsBrowseHistory' => 'ba042fdf72cf2c92782b6df31ed747f5f47e5bba2f0a42250f09c948daa902b5a:2:{i:0;s:18:"goodsBrowseHistory";i:1;s:2:"27";}',
'advanced-mobile' => 'h5g81v6rh207s9e6on3h2721fj',
'advanced-frontend' => 't39okobnch4nccopmh5tfg8p3s',
'_csrf-frontend' => 'a28cf518b1b7a2d0dff529c98a30ee0f0809d084d07652700a7a7bdff65b3aeba:2:{i:0;s:14:"_csrf-frontend";i:1;s:32:"dOgR1sW-x8-JZKY2WKhe3dSxtROaEMi3";}',
'__session:0_8248216370763841:' => 'http:',
];
$_SESSION = [
'__flash' => [],
'userRole' => 'buyer',
'__id' => 4,
'__authKey' => 'PDH9apQNcIi2vKQPbzHQf_9gSk2t-H6g',
];
2023-02-26, 00:32:27
Apache/2.4.39 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9a mod_log_rotate/1.02
Yii Framework/2.0.41.1
2.0.41.1 PHP 7.2.9
Status 500 Route search/index
Log 51 1
Time 366 ms Memory 8.980 MB
DB 23 24 ms
User 4
about:blank