How can I get the executed query in Laravel 3/4, using Fluent Query Builder or Eloquent ORM.
(posts (id, user_id, ...))
In Laravel 4, you have to call
DB::getQueryLog() to get all ran queries.
$queries = DB::getQueryLog(); $last_query = end($queries);
In Laravel 3, you can get the last executed query from an
Eloquent model calling the static method
last_query on the
This, however, requires that you enable the
profiler option in
application/config/database.php. Alternatively you could, as @dualed mentioned, enable the
profiler option, in
application/config/application.php or call
DB::profile() to get all queries ran in the current request and their execution time.