laravel 打印sql

DB::connection()->enableQueryLog();#开启执行日志
$goodLists = DB::table('ds_goods')->where(['goods_advword'=>['like' => "%{$title}%"],'goods_state' => 1])->orWhere(function($query) use ($title) {
  // 闭包添加搜索条件
    $query->where(['goods_name'=>['like' => "%{$title}%"],'goods_state' => 1]);
})->get();
dd(DB::getQueryLog()); //获取查询语句、参数和执行时间
原文地址:https://www.cnblogs.com/yjhsm/p/13573038.html