Skip to content

Instantly share code, notes, and snippets.

@Bazsmagister
Last active April 12, 2021 07:21
Show Gist options
  • Save Bazsmagister/8c049675d422eb18cef360bfa6e63ce8 to your computer and use it in GitHub Desktop.
Save Bazsmagister/8c049675d422eb18cef360bfa6e63ce8 to your computer and use it in GitHub Desktop.
laravel query var_dumper
DB::listen(function ($query) {
var_dump($query->sql, $query->bindings);
});
----
source:
https://stackoverflow.com/questions/27753868/how-to-get-the-query-executed-in-laravel-5-dbgetquerylog-returning-empty-ar
You will need to enable the query log by calling:
DB::enableQueryLog();
// and then you can get query log
dd(DB::getQueryLog());
or register an event listener:
DB::listen(
function ($sql, $bindings, $time) {
// $sql - select * from `ncv_users` where `ncv_users`.`id` = ? limit 1
// $bindings - [5]
// $time(in milliseconds) - 0.38
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment