The FIELD()
function is MySQL specific and therefore not part of the Doctrine 2 library.
You can use a custom DQL function, which is already created by the lead developer of Doctrine (Benjamin Eberlei). https://github.com/beberlei/DoctrineExtensions/.
Also I'm pretty sure you need to define the FIELD()
function as hidden because you can't use functions in the order by in DQL. Marking it as hidden will prevent the function output to be hydrated in the resultset. Something in the line of:
$query=$this->_em->createQuery("SELECT u, field(u.id, 14469, 685) as HIDDEN field FROM UserBundle:User u WHERE
u.id = 14469 OR
u.id = 685
ORDER BY u.id, field
");