📜  如何在 laravel 中获取查询日志 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:18.343000             🧑  作者: Mango

代码示例1
Method #1
instead of ->get use ->toSql() on query 
$users = User::orderBy('name', 'asc')->toSql();

echo $users;

// Outputs the string:
'select * from `users` order by `name` asc'
Method # 2

DB::enableQueryLog();

// and then you can get query log

dd(DB::getQueryLog());