Last active
December 25, 2015 08:29
-
-
Save fsalehpour/6947119 to your computer and use it in GitHub Desktop.
SQL query logging for Laravel 4. Put it somewhere to run, like app/filters.php. Thanks to Shawn McCool
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
<?php | |
// Logs SQL queries as info | |
// Thanks to @ShawnMcCool | |
// Link to the original content by Shawn McCool: | |
// https://github.com/LaravelIO/laravel-io/blob/master/app/filters.php#L71 | |
Event::listen('illuminate.query', function($sql, $bindings) | |
{ | |
foreach ($bindings as $val) { | |
$sql = preg_replace('/\?/', "'{$val}'", $sql, 1); | |
} | |
Log::info($sql); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment