Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2844

Doctrine\ORM\Query\QueryException raised when using Criteria object with more than one condition in repository.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.4.1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      $userRepository = $em->getRepository ('User\Entity\User');
      $date = '2013-12-02';
      $dateFrom = new \DateTime ($date);
      $fateTo = (new \DateTime ($date))->add (new \DateInterval ('P1D');
      
      // OK
      $criteria = new \Doctrine\Common\Collections\Criteria ();
      $criteria
          ->where ($criteria->expr ()->gte ('signedIn', $dateFrom))
          ->andWhere ($criteria->expr ()->lt ('signedIn', $dateTo));
      var_dump ($userRepository->matching ($criteria));
      
      
      // NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
      $criteria = new \Doctrine\Common\Collections\Criteria ();
      $criteria
          ->where ($criteria->expr ()->gte ('user.signedIn', $dateFrom))
          ->andWhere ($criteria->expr ()->lt ('user.signedIn', $dateTo));
      var_dump ($userRepository->createQueryBuilder ('user')->addCriteria ($criteria)->getQuery ()->getResult ());
      
      
      // NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
      $criteria
          ->where ($criteria->expr ()->eq ('user.active', true))
          ->andWhere ($criteria->expr ()->eq ('user.active', true));
          //->orWhere ($criteria->expr ()->eq ('user.active', true));
      var_dump ($userRepository->createQueryBuilder ('user')->addCriteria ($criteria)->getQuery ()->getResult ());
      

        Activity

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Yana Key
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: