laravel 取sql语句

 \DB::connection()->enableQueryLog();

some sql action...

$query = \DB::getQueryLog();
$lastQuery = end($query);  

dd($lastQuery);

 

php artisan tinker

DB::listen(function($sql){ var_dump($sql);  });

 

你可能感兴趣的:(laravel 取sql语句)