Get the Query Executed in Laravel 3/4
问题 How can I retrieve the raw executed SQL query in Laravel 3/4 using Laravel Query Builder or Eloquent ORM? For example, something like this: DB::table(\'users\')->where_status(1)->get(); Or: (posts (id, user_id, ...)) User::find(1)->posts->get(); Otherwise, at the very least how can I save all queries executed to laravel.log? 回答1: Laravel 4+ In Laravel 4 and later, you have to call DB::getQueryLog() to get all ran queries. $queries = DB::getQueryLog(); $last_query = end($queries); Or you can