gpt4 book ai didi

laravel - 在 Laravel 5.2 中工作的查询在 Laravel 5.3 中给我错误

转载 作者:行者123 更新时间:2023-12-04 10:23:52 24 4
gpt4 key购买 nike

此查询适用于 5.2:

    $galleries = Gallery::with(array(
'images' => function ($query) {
$query->orderBy('order', 'asc');
}
))
->with('votes')
->leftJoin('votes', 'votes.votable_id', '=', 'gallery.id')
->selectRaw(
'gallery.*, count(case votes.status when "upvote" then 1 else null end) - count(case votes.status when "downvote" then 1 else null end) as points'
)
->where('votes.votable_type','App\Gallery')
->groupBy('gallery.id')
->orderBy('points', 'desc')
->published()->orderBy('gallery.created_at', 'desc')->paginate(30);

我正在尝试选择所有有投票的画廊,当我在 5.3 中运行它时,我得到了这个
 1/2 PDOException in Connection.php line 333: SQLSTATE[42000]: 
Syntax error or access violation: 1055 'images.gallery.title' isn't in GROUP BY

SQLSTATE[42000]: Syntax error or access violation: 1055 'images.gallery.title' isn't in
GROUP BY (SQL: select gallery.*, count(case votes.status when "upvote" then 1 else null end) - count(case votes.status when "downvote" then 1 else null end)
as points from `gallery` left join `votes` on `votes`.`votable_id` = `gallery`.`id`
where `votes`.`votable_type` = App\Gallery and `published` = 1 group by `gallery`.`id`
order by `points` desc, `gallery`.`created_at` desc limit 30 offset 0)

最佳答案

转到您的 config/database.php 文件夹。在 mysql 配置数组中,更改 strict => truestrict => false ,一切都会很好地工作。

关于laravel - 在 Laravel 5.2 中工作的查询在 Laravel 5.3 中给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39120862/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com