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