以下示例是关于Php中包含laravel show debug query sql用法的示例代码,想了解laravel show debug query sql的具体用法?laravel show debug query sql怎么用?laravel show debug query sql使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。
// Debug SQL query
// app/Providers/AppServiceProvider.php
public function boot()
{
//...
$this->debugQueries();
}
protected function debugQueries()
{
if (env('APP_DEBUG_QUERIES')) {
DB::listen(function ($query) {
error_log(
"Query [$query->time ms]: $query->sql\n"
. "Params: " . print_r($query->bindings, true)
);
});
}
}
本文地址:https://www.itbaoku.cn/snippets/785221.html