Hello I worked with Symfony2 and Doctrine.
I want to order by my custom order with doctrine
SELECT id_product, pro_name FROM product ORDER BY FIELD(id_product,3,5,2)
I have tried
$rang_1=array(3,5,2);
$products = $em->getRepository('CompanyMyBundle:Product')->findBy(array('public' => 1,'idProduct'=>$rang_1), array('idProduct'=>$rang_1), 5);
AND
$sql = $em->createQuery("SELECT p FROM CompanyMyBundle:Product p WHERE l.public = 1 AND l.idProduct IN (".implode(',',$rang_1).") ORDER BY FIELD(l.idProduct,".implode(',',$rang_1).")")->setMaxResults(5);
Any suggestion?