Restore SQL debug output

apparently something changed with hasListeners()
This commit is contained in:
Tony Murray
2020-06-15 22:25:10 -05:00
parent c90404e9a9
commit 7334f629ba

View File

@@ -80,9 +80,10 @@ class Laravel
public static function enableQueryDebug()
{
static $sql_debug_enabled;
$db = Eloquent::DB();
if ($db && !$db->getEventDispatcher()->hasListeners('Illuminate\Database\Events\QueryExecuted')) {
if ($db && !$sql_debug_enabled) {
$db->listen(function (QueryExecuted $query) {
// collect bindings and make them a little more readable
$bindings = collect($query->bindings)->map(function ($item) {
@@ -99,6 +100,7 @@ class Laravel
c_echo("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n");
}
});
$sql_debug_enabled = true;
}
}