0

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!

1 Answer 1

2

It is just a typo, typeLable should be without quotes:

->addSelect(" (CASE WHEN f.type = 'p' THEN 'panel' ELSE 'glass' END) as typeLable ")
Sign up to request clarification or add additional context in comments.

4 Comments

Right, but now I get this error : Expected argument of type "object or array", "string" given
what is the whole call stack? What is causing this error?
g is object, so: ->andWhere("g = :gamme") and ->setParameter("gamme", $gammeEntity)
The latest issue wasn't part of this trac. Thanks everything is ok now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.