title: Define the order of result of a SQL Query in Doctrine
body: <p>My concrete problem in a Symfony2 - Doctrine application:</p>
  
  <p>I want to order search results of a query in a self defined order (w.winnerType: 'main','special', 'normal', 'web) which is <strong>NOT</strong> ASC or DSC,</p>
  
  <p>I've tried several versions as proposed in <a href="https://stackoverflow.com/questions/866465/order-by-the-in-value-list">ORDER BY the IN value list</a> (link to Stackoverflow)</p>
  
  <p>Version 1</p>
  
  <pre><code>  $em = $this-&gt;getDoctrine()-&gt;getManager();
    $query = $em-&gt;createQuery (
       "select w
          FROM MyBundle:Winner w
          WHERE
              w.winnerType IN ('main', 'special', 'normal', 'web')  
  .
          ORDER BY w.winnerType='main' DESC, w.winnerType='special' DESC,
              w.winnerType='normal' DESC, w.winnerType='web' DESC  
         ") ;
  </code></pre>
  
  <p>This gives the error message:</p>
  
  <blockquote>
    <p>[Syntax Error]: Error Expected end of string, got '=' </p>
  </blockquote>
  
  <p>Version 2</p>
  
  <pre><code>ORDER BY FIELD (w.winnerType, 'main','special', 'normal', 'web')    
  </code></pre>
  
  <p>Gives the error message</p>
  
  <blockquote>
    <p>[Syntax Error]  Error: Expected known
    function, got 'FIELD'</p>
  </blockquote>
  
  <p>Version 3</p>
  
  <pre><code>ORDER BY CASE w.winnerType 
                      WHEN 'main' THEN 1
                      WHEN 'special' THEN 2
                      WHEN 'normal' THEN 3
                      WHEN 'web' THEN 4
                      ELSE 999
  </code></pre>
  
  <p>Gives the error message</p>
  
  <blockquote>
    <p>QueryException: [Syntax Error] line 0, col 314: Error: Expected end of string, got 'w'</p>
    
    <p>Debug Info: 
    CRITICAL - Uncaught PHP Exception Doctrine\ORM\Query\QueryException:
    "[Syntax Error] line 0, col 314: Error: Expected end of string, got
    'w'" at
    C:\Users\sDev2\xampp\htdocs\bvbp\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php</p>
  </blockquote>
  
  <p>None of the standard SQL custom sort methods (posted in several stackoverflow items) works in my symfony/doctrine environment. </p>
  
  <p>If I use the "ASC" parameter (which does not solve my problem): I don't have problems in my Symfony application</p>
  
  <p>Example (working without problems)</p>
  
  <pre><code>  $em = $this-&gt;getDoctrine()-&gt;getManager();
    $query = $em-&gt;createQuery (
       "select w
          FROM MyBundle:Winner w
          WHERE
              w.winnerType IN ('main', 'special', 'normal', 'web')  
  .
          ORDER BY w.winnerType ASC  
         ") ;
  </code></pre>
  
  <p>What is the syntax to be used in symfony2 / doctrine? 
  Thanks</p>