Sometimes it's useful for debugging purposes to preview the query that Laravel generates with Eloquent/Fluent.
(!) In Laravel 5 you should enable do
Then after placing your final statement:
DB::table('users')->where('name', '=', 'Aknavi')->get();
dd(DB::getQueryLog()); - it will return the SQL and the bindings of the last queries that were executed.
In Laravel 4
queryLogging is enabled by default, so you should just do:
In Laravel 3 you can run
But you should have
profiler enabled in
Or you can use the profiler to get all queries executed for the current request and their execution time.