Answer the question
In order to leave comments, you need to log in
How to add a calculated field with logical operators in doctrine ORM?
I have a query like this:
$asins = $asinRepository->createQueryBuilder('asin')
->setParameter('master', $user->getId())
->addSelect('asin.isInWork AND asin.master = :master AS HIDDEN isInWorkSelf')
->addOrderBy('isInWorkSelf', 'desc')
->getQuery()
->getResult();
[Syntax Error] line 0, col 27: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got 'AND'
SELECT
asin,
asin.isInWork AND asin.master = :master AS HIDDEN isInWorkSelf
FROM App\Entity\Asin asin
ORDER BY isInWorkSelf desc
->addSelect('CASE WHEN asin.master = :master THEN asin.isInWork ELSE 0 END AS HIDDEN isInWorkSelf')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question