【发布时间】:2019-11-28 00:30:09
【问题描述】:
我有这个查询,但它不起作用
$order = Order::select('*', DB::raw('count(*) as num_product'),
DB::raw('count(status) where status = 1 as accepted')) // ERROR HERE
->groupBy(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d')"))->get();
我想显示接受的订单数量,例如:2 of 5
【问题讨论】:
-
为什么你不使用简单的 Laravel Eloquent:
$order = Order::where('status', 1)->count();