<?php
private function printSqlLog()
{
$queries = \DB::getQueryLog();
$time = 0;
foreach($queriesas$key => $query) {
// 处理方法参考http://stackoverflow.com/a/25183270/1373875
$sql = $query['query'];
foreach ($query['bindings'] as $val) {
$sq = preg_replace('/\?/',"'{$val}'", $sql, 1);
}
$time += $query['time'];
\Log::info('['. ($key+1) .'] ' . $sql . ' ['.$query['time'] . 'ms]');
\Log::info('total time ' . $time . 'ms');
}
网友评论