Skip to content

Commit 7b58b2d

Browse files
authored
解决 sql 语句中带 DATE_FORMAT 时的 vsprintf 不正确的问题
eg: >>> vsprintf("select DATE_FORMAT(created_at, '%Y-%m') from `users`", ['a', 'b']) => "select DATE_FORMAT(created_at, '-') from `users`" >>> vsprintf("select DATE_FORMAT(created_at, '%%Y-%%m') from `users`", ['a', 'b']) => "select DATE_FORMAT(created_at, '%Y-%m') from `users`"
1 parent a6ad71b commit 7b58b2d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function boot()
2525
{
2626
Log::info('============ URL: '.request()->fullUrl().' ===============');
2727
DB::listen(function (QueryExecuted $query) {
28-
$sqlWithPlaceholders = str_replace('?', '%s', $query->sql);
28+
$sqlWithPlaceholders = str_replace(('?','%'), ('%s','%%'), $query->sql);
2929
3030
$bindings = $query->connection->prepareBindings($query->bindings);
3131
$pdo = $query->connection->getPdo();

0 commit comments

Comments
 (0)