laravel 记录 sql
// 开启记录
\Illuminate\Support\Facades\DB::connection()->enableQueryLog();
// 打印记录
$bindings = \Illuminate\Support\Facades\DB::getQueryLog();
$data = [];
foreach ($bindings as $k => $b) {
$bi = $b['bindings'];
$bi = array_map(function ($a) {
return '\'' . $a . '\'';
}, $bi);
$sql = str_replace('?', '%s', $b['query']);
$sql2 = sprintf($sql, ...$bi);
$data[$k] = $sql2;
}
dd($data);
最后更新于 2023-11-30 08:55:15 并被添加「」标签,已有 686 位童鞋阅读过。
此处评论已关闭