Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1021

Automatically infer type when DateTime is used as parameter in queries

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.1.1
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None

      Description

      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.

        Activity

        Hide
        Guilherme Blanco added a comment -

        This was already fixed by ParameterTypeInferer released in 2.1

        Show
        Guilherme Blanco added a comment - This was already fixed by ParameterTypeInferer released in 2.1

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Karsten Dambekalns
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: