Skip to content

Instantly share code, notes, and snippets.

@thewinterwind
Created November 9, 2013 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewinterwind/7381673 to your computer and use it in GitHub Desktop.
Save thewinterwind/7381673 to your computer and use it in GitHub Desktop.
Helper function for viewing queries ran in Laravel 4
<?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