Skip to content

Instantly share code, notes, and snippets.

@rrdial
Created August 20, 2018 15:51
Show Gist options
  • Save rrdial/77258caf08161156452bd6ac2744378d to your computer and use it in GitHub Desktop.
Save rrdial/77258caf08161156452bd6ac2744378d to your computer and use it in GitHub Desktop.
Laravel Database Query Debugging
<?php
\DB::listen(function($query) {
static $i = 0;
$sql = str_replace('?', '"%s"', $query->sql);
\Log::debug(sprintf('********** Query number %d ********** ', ++$i) . vsprintf($sql, $query->bindings));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment