0

I have the following doctrine dql query, I cant see it being much different from manual but yet I get the following error:

Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT s FROM \SessionStorage s WHERE id= ?1 AND expireAt > NOW()'

$dql = "SELECT s FROM SessionStorage s WHERE id= ?1 AND expireAt > NOW()";
        $sessionstorage = $this->em->createQuery($dql)
            ->setParameter(1,$this->cookieManager->getCookie('session')->getValue())
            ->getResult();

I have tried seperating the createQuery from the setparameter but it fails at the creatQuery, but it gives not a single clue whats wrong with it. According to the documentation it should work, its very simple basic code and it works if I make it a normal pdo request.

What have I tried? i've tried using \SessionStorage, Entities\Sessionstorage, src\SessionStorage.

Tried removing the expireAt > NOW()

Changed the var from ? to :id

Tried without the s in SessionStorage s

i've googled but all I found with this error were a LOT of broken websites.

Since the doctrine documentation is cluttered as hell and unclear as it can be by not explaining what does what i'm at a loss what is wrong with this really really simple query.

Can someone please enlighten me what this query does wrong? I really dont understand why such a simple query gives such an error.

Tschallacka
  • 27,901
  • 14
  • 88
  • 133
  • 1
    When you name an entity in DQL, this must be done by using the absolute namesapce of the entity. I run an application on ZF wihch loads entityes from BT\Model\Entity\. Can you double check this? Also, i'm not sure if you can use NOW(), try using CURRENT_TIMESTAMP(). – fkupper Oct 24 '14 at 11:45
  • Im not using namespaces. No need for that level of complication yet. It was the current stamp. Weird that they wont support now() – Tschallacka Oct 24 '14 at 12:19
  • Btw. Could you post it in an answer so i can accept it? – Tschallacka Oct 24 '14 at 12:19

1 Answers1

1

Use CURRENT_TIMESTAMP() or CURRENT_DATE() instead of NOW().

fkupper
  • 520
  • 3
  • 9