Last active
April 12, 2021 07:21
-
-
Save Bazsmagister/8c049675d422eb18cef360bfa6e63ce8 to your computer and use it in GitHub Desktop.
laravel query var_dumper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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