laravel打印执行的sql语句的方法
第一种:
App\User::query()
->where('created_at', '<', now()->subYear())
->with('assignedApps', 'courses')
->orderBy('email', 'asc')
->limit(5)
->toSql();
//
$product = Product::where('id',77)->toSql();
echo $product;
第二种:
DB::enableQueryLog();
App\User::query()
->where('created_at', '<', now()->subYear())
->with('assignedApps', 'courses')
->orderBy('email', 'asc')
->limit(5)
->get();
echo DB::getQueryLog();