DDC-1021: Automatically infer type when DateTime is used as parameter in queries #1272

Open
opened 2026-01-22 13:07:54 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 8, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user k-fish:

Given $date instanceof \DateTime, instead of this:

$this->entityManager->createQuery(' ... p.date >= :pdate')
  ->setParameters(array('pdate' => $date), array('pdate' => 'datetime'))
  ->execute()

I would love to be able to use this:

$this->entityManager->createQuery(' ... p.date >= :pdate')
  ->execute(array('pdate' => $date))

Even when using setParameters() - which you need to do, e.g. when using getSingleResult(), it would be nice to be able to leave that out for DateTime instances - seems to be about the only thing that is not handled transparently.

Originally created by @doctrinebot on GitHub (Feb 8, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user k-fish: Given `$date instanceof \DateTime`, instead of this: ``` $this->entityManager->createQuery(' ... p.date >= :pdate') ->setParameters(array('pdate' => $date), array('pdate' => 'datetime')) ->execute() ``` I would love to be able to use this: ``` $this->entityManager->createQuery(' ... p.date >= :pdate') ->execute(array('pdate' => $date)) ``` Even when using `setParameters()` - which you need to do, e.g. when using `getSingleResult()`, it would be nice to be able to leave that out for DateTime instances - seems to be about the only thing that is not handled transparently.
admin added the Improvement label 2026-01-22 13:07:54 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1272