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

Closed
opened 2026-01-22 13:07:57 +01:00 by admin · 2 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:57 +01:00
admin closed this issue 2026-01-22 13:07:57 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 16, 2011):

Comment created by @guilhermeblanco:

This was already fixed by ParameterTypeInferer released in 2.1

@doctrinebot commented on GitHub (Aug 16, 2011): Comment created by @guilhermeblanco: This was already fixed by ParameterTypeInferer released in 2.1
Author
Owner

@doctrinebot commented on GitHub (Aug 16, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 16, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1274