Getting executed queries #query-logging
Getting full list of SQL queries executed during a request could be
very helpful in debugging. There is the simple way to return an array of all
queries, either produced by Eloquent or
Starting with Laravel 5 you need to enable query logging first. This is disabled by default to save some memory. Place following code before you execute any query.
Then you can fetch the queries using
DB::getQueryLog(). You can perform
any operations on returned array or just use builtin
dd() function if you
need quick dump.
<?php $queries = DB::getQueryLog(); dd($queries); // Just dump the array and stop script execution
The array is multidimensional - entry for each query consists of SQL command itself and nested array with currently binded values.