@@ -36,8 +36,10 @@ public function handle(QueryExecuted $event): void
36
36
? $ event ->connection ->getPdo ()
37
37
: null ;
38
38
39
+ $ dateFormat = $ event ->connection ->getQueryGrammar ()->getDateFormat ();
40
+
39
41
$ bindings = $ event ->connection ->prepareBindings ($ event ->bindings );
40
- $ bindings = \array_map (fn ($ value ) => $ this ->prepareValue ($ pdo , $ value ), $ bindings );
42
+ $ bindings = \array_map (fn ($ value ) => $ this ->prepareValue ($ pdo , $ dateFormat , $ value ), $ bindings );
41
43
42
44
$ query = $ this ->prepareQuery ($ event ->sql , $ bindings );
43
45
@@ -63,7 +65,7 @@ protected function prepareQuery(string $query, array $bindings): string
63
65
return $ query ;
64
66
}
65
67
66
- protected function prepareValue (?\PDO $ pdo , $ value ): string
68
+ protected function prepareValue (?\PDO $ pdo , string $ dateFormat , $ value ): string
67
69
{
68
70
if (\is_null ($ value )) {
69
71
return 'NULL ' ;
@@ -81,18 +83,18 @@ protected function prepareValue(?\PDO $pdo, $value): string
81
83
return $ this ->quote ($ pdo , '[BINARY DATA] ' );
82
84
}
83
85
84
- if (\is_object ($ value ) && \method_exists ($ value , 'toString ' )) {
85
- $ value = $ value ->toString ();
86
- }
87
-
88
86
if ($ value instanceof \DateTimeInterface) {
89
- $ value = $ value ->format (' Y-m-d H:i:s ' );
87
+ $ value = $ value ->format ($ dateFormat );
90
88
}
91
89
92
90
if ($ value instanceof \Stringable) {
93
91
$ value = \strval ($ value );
94
92
}
95
93
94
+ if (\is_object ($ value ) && \method_exists ($ value , 'toString ' )) {
95
+ $ value = $ value ->toString ();
96
+ }
97
+
96
98
// objects not implementing __toString() or toString() will fail here
97
99
return $ this ->quote ($ pdo , \strval ($ value ));
98
100
}
0 commit comments