/**
* Notes:开始打印sql
* User: smaller_fan
* Date: 2020/7/2
* Time: 10:06
*/
function begin_sql(){
\Illuminate\Support\Facades\DB::enableQueryLog();
}
/**
* Notes:结束打印sql
* User: smaller_fan
* Date: 2020/7/2
* Time: 10:06
*/
function dd_sql(){
$res = \Illuminate\Support\Facades\DB::getQueryLog();
$all_time = array_sum(array_column($res,'time'));
dd(['all_time'=>$all_time,'all_sql'=>$res]);
}
来源:oschina
链接:https://my.oschina.net/guozhouyuan/blog/4511613