title: How to ORDER BY CASE in Doctrine2 (Symfony2)
body: <p>I want to run this query by using Doctrine in Symfony 2.3. But it seems like Doctrine does not understand CASE statement. Can anyone help? Thank you in advance!</p>
  
  <pre><code>SELECT max(id) id, name
  FROM cards
  WHERE name like '%John%'
  GROUP BY name
  ORDER BY CASE WHEN name like 'John %' THEN 0
             WHEN name like 'John%' THEN 1
             WHEN name like '% John%' THEN 2
             ELSE 3
        END, name
  </code></pre>