Skip to content

Commit 32ee741

Browse files
authored
avoid vsprintf() error
vsprintf(): Too few arguments when use \DB::update(DB::raw($q)
1 parent 96583c4 commit 32ee741

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ServiceProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ public function boot()
3232

3333
$bindings = $query->connection->prepareBindings($query->bindings);
3434
$pdo = $query->connection->getPdo();
35-
$realSql = vsprintf($sqlWithPlaceholders, array_map([$pdo, 'quote'], $bindings));
36-
$duration = $this->formatDuration($query->time / 1000);
35+
if (count($bindings)) {
36+
$pdo = $query->connection->getPdo();
37+
$realSql = vsprintf($sqlWithPlaceholders, array_map([$pdo, 'quote'], $bindings));
38+
} else {
39+
$realSql = $sqlWithPlaceholders;
40+
}
3741

3842
Log::debug(sprintf('[%s] %s | %s: %s', $duration, $realSql, request()->method(), request()->getRequestUri()));
3943
});

0 commit comments

Comments
 (0)