There are already several questions in regards to logging the SQL query in Laravel 4. But I've tried almost all of them and it's still not working the way I want.
Here's my situation
- in my php view file, I make AJAX request to the server
The AJAX request is received and runs a RAW parameterized Postgres SQL query (e.g.
DB::select('select * from my_table where id=?', array(1))
If I use
Event::listen('illuminate.query', function($sql)
{
Log::error($sql);
});
I just get "select * from my_table where id=?" as the log message without the ID value actually populated.
If I use
$queries = DB::getQueryLog();
$last_query = end($queries);
Log::error(print_r($last_query, true));
I still don't have the final SQL query with the ID populated.
Finally, if I use a logging tool like https://github.com/loic-sharma/profiler - it doesn't display anything since I'm making an AJAX request.
Have I exhausted my options? Is there still another better way?
See Question&Answers more detail:os