有些时候 需要用到mysql内置函数,laravel文档没有写清楚
文档里有个 DB::raw()
$sum = '*,
sum(register_user) as register_user,
sum(pv) as pv,
sum(uv) as uv,
sum(login_user) as login_user';
$user = User::select(DB::raw($sum))
->where("$search",'like',"%$searchNum%")
->whereBetween('savetime',[$startTime,$endTime])
->groupBy(DB::raw("WEEKOFYEAR(FROM_UNIXTIME(savetime, '%Y-%m-%d %H:%i:%S'))"),'IP')
->orderBy($orderBy,$order);
利用DB::raw
就可以使用mysql 内置函数
本站(PHP --> Golang)已重构,代码开源
当你能力不能满足你的野心的时候,你就该沉下心来学习