我理解以下查询是如何工作的。
$user_info = DB::table('usermetas')
->select('browser', DB::raw('count(*) as total'),DB::raw("DATE_FORMAT(created_at,'%h:%i %p') as day")
->groupBy('browser')
->get();
这将得到结果
[{"browser":"GC","total":1,"day":"04:27 AM"},{"browser":"GC","total":2,"day":"04:27 AM"},
{"browser":"MF","total":1,"day":"05:27 AM"},
{"browser":"MF","total":1,"day":"07:27 AM"}]
是否可以获得结果输出。
[{"browser":"GC","total":1,"day":"04:27 AM"},{"browser":"GC","total":2,"day":"04:27 AM"},
{"browser":"MF","total_test":1,"day":"05:27 AM"},
{"browser":"MF","total_test":1,"day":"07:27 AM"}]
我们可以为计数字段指定不同的名称吗?