Reputation: 87
I would like to do something like :
return $qb
->select("f, g")
->addSelect(" (CASE WHEN (f.type = 'p') THEN 'panel' ELSE 'glass' END) as 'typeLable' ")
->from("Win4uAdminBundle:Filling", "f")
->join("f.gammes", "g")
->andWhere("f.isActive = :active")
->andWhere("g.id = :gamme")
->setParameter("active", 1)
->setParameter("gamme", $gammeId)
But doesn't work. error is :
[Syntax Error] line 0, col 74: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got 'typeLable'
The goal is select the type and translate it in the query.
Thanks!
Upvotes: 0
Views: 1995
Reputation: 10890
It is just a typo, typeLable
should be without quotes:
->addSelect(" (CASE WHEN f.type = 'p' THEN 'panel' ELSE 'glass' END) as typeLable ")
Upvotes: 2