File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,21 @@ and for managed entities. If you want to set a type explicitly you can call
255255the third argument to ``setParameter() `` explicitly. It accepts either a PDO
256256type or a DBAL Type name for conversion.
257257
258+ .. note ::
259+
260+ Even though passing DateTime instance is allowed, it impacts performance
261+ as by default there is an attempt to load metadata for object, and if it's not found,
262+ type is inferred from the original value.
263+
264+ .. code-block :: php
265+
266+ <?php
267+
268+ use Doctrine\DBAL\Types\Types;
269+
270+ // prevents attempt to load metadata for date time class, improving performance
271+ $qb->setParameter('date', new \DateTimeImmutable(), Types::DATE_IMMUTABLE)
272+
258273 If you've got several parameters to bind to your query, you can
259274also use setParameters() instead of setParameter() with the
260275following syntax:
@@ -581,4 +596,3 @@ same query of example 6 written using
581596 ->add('from', new Expr\From('User', 'u'))
582597 ->add('where', new Expr\Comparison('u.id', '=', '?1'))
583598 ->add('orderBy', new Expr\OrderBy('u.name', 'ASC'));
584-
You can’t perform that action at this time.
0 commit comments