登录以后,点击个人主页报错:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'peth5.aws_answer.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
找到报错的地方,改一下代码,或者改一下MySQL的配置均可。改MySQL配置的话,就是让MySQL支持非聚合函数列不出现在group by 后面,不推荐这种。
那就改代码吧。
错误SQL:
SELECT * FROM `aws_answer` WHERE `status` = 1 AND `question_id` IN (2,1) GROUP BY `question_id` ORDER BY `is_best` DESC,`agree_count` DESC,`comment_count` DESC
报错的文件位置在:
Answer::getHotAnswerByIds([2, 1, 1]) in LogHelper.php line 277
app/common/library/helper/LogHelper.php
if ($last_answers = Answer::getHotAnswerByIds($question_ids))
if ($last_answers = Answer::getHotAnswerByIds($question_ids,"any_value(id) as id,any_value(content) as content,any_value(against_count) as against_count,any_value(agree_count) as agree_count,any_value(uid) as uid,any_value(comment_count) as comment_count,any_value(uninterested_count) as uninterested_count,any_value(thanks_count) as thanks_count,any_value(answer_user_ip) as answer_user_ip,any_value(answer_user_local) as answer_user_local,any_value(is_anonymous) as is_anonymous,any_value(publish_source) as publish_source,any_value(status) as status,any_value(is_best) as is_best,any_value(best_uid) as best_uid,any_value(best_time) as best_time,any_value(force_fold) as force_fold,any_value(search_text) as search_text,any_value(popular_value) as popular_value,any_value(popular_value_update) as popular_value_update,any_value(create_time) as create_time,any_value(update_time) as update_time,question_id"))