Search code examples
doctrine-ormdoctrine-query

whats wrong with this doctrine query?


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.


Solution

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