문제

I've a query where I need to find out, if a string contains some substring. And I want to order by the result.

Here is my initial idea:

SELECT p, LOCATE(:term, p.name) > 0 inName
FROM xy p
ORDER BY inName, p.name

which lead to Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '>'. After reading the documentation I understand why.

Is there any simple way, how to use "greater than" in select with Doctrine2?

도움이 되었습니까?

해결책

It seems like there's no way to handle the "greater than" in the way I meant. The only solution I was able to find is to define my own IF function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top