راکت
heather
heather
توسط heather مطرح شد
حل
3 پاسخ

کار نکردن تابع latest یا orderBy در Eloquent

سلام دوستان گرامی ...
نمی دونم چرا این تابع latest یا orderBy در این کدم کار نمی کنه و ارور میده :

        $month = 12;
        $paymentSuccess = Payment::selectRaw('monthname(created_at) month , count(*) published')
            ->where('created_at','>',Carbon::now()->subMonth($month))
            ->where('payment', true)
            ->groupBy('month')
            ->orderBy('created_at','desc')
            ->get();
Error:
Illuminate \ Database \ QueryException (42000)
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'syber.payments.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select monthname(created_at) month , count(*) published from `payments` where `created_at` > 2018-02-23 08:03:22 and `payment` = 1 group by `month` order by `created_at` desc)

ثبت پرسش جدید
رایموند
رایموند
تخصص :مختصص وردپرس - برنامه نویس لاراول
@Raymond7 سال پیشمطرح شد
heather
heather
تخصص :برنامه نویس بک اند
@heather7 سال پیشمطرح شد
0

البته دوستان باید اینم اضافه کنم که وقتی هم کد رو بدون orderBy استفاده می کنی جواب میده ولی وقتی اینو اضافه می کنی ارور میده..انگار این تابع با groupBy مشکل داره.


heather
heather
تخصص :برنامه نویس بک اند
@heather7 سال پیشمطرح شد
0

درود بر شما...
@RaymondDragon
من رفتم داخل config/database.php و در اونجا strict رو false قرار دادم حل شد...فقط اینکار و کردم چی شد؟؟
مشکلی پیش نمیاد؟


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام