Larevel5.1 打印SQL语句
为了方便调试,开发时需要打印sql。
方法一(全局打开):
SQL打印默认是关闭的,
需要在/vendor/illuminate/database/Connection.php中打开。
protected $loggingQueries =
true;
然后使用方法:
$result = DB::table(
'user')->
get();
$log =
DB::getQueryLog();
dd($log);
方法二(临时打开):
DB::connection()->
enableQueryLog();
$result = DB::table(
'user')->
get();
$log =
DB::getQueryLog();
dd($log);
转载于:https://www.cnblogs.com/gyfluck/p/10032911.html
相关资源:JAVA上百实例源码以及开源项目