Created
November 9, 2013 04:27
-
-
Save thewinterwind/7381673 to your computer and use it in GitHub Desktop.
Helper function for viewing queries ran in Laravel 4
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 | |
if (!function_exists('sql')) { | |
function sql($detailed = false) { | |
if ($detailed) { | |
Event::listen("illuminate.query", function($query, $bindings, $time, $name) { | |
$queries = DB::getQueryLog(); | |
echo '<pre>'; | |
foreach(end($queries) as $item) { | |
var_dump($item); | |
} | |
echo '</pre>'; | |
}); | |
} else { | |
Event::listen("illuminate.query", function($sql) { | |
echo '<pre>'; | |
print_r($sql); | |
echo '</pre>'; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment