title: SET a variable into DQL query
body: <ul>
  <li><p>I want to set a variable into a DQL query on the basis of condition </p></li>
  <li><p>case when both varibale value are matches the set variable rank. </p></li>
  </ul>
  
  <p>dql query </p>
  
  <pre><code> $q=$this-&gt;em-&gt;createQuery("select distinct u.id,u.city,u.country,u.designation FROM Entities\User u JOIN Entities\EventVisitor evt_vstr WITH evt_vstr.user = u.id WHERE (
                             CASE
                              WHEN $a =u.designation THEN SET @rank=1
                              WHEN $b =u.country THEN SET @rank=2
                              WHEN $c =u.city THEN SET @rank=3
                              WHEN $d =u.company THEN @rank=4
                              END) order by @rank")
  
  
                               -&gt;setFirstResult($i)
                               -&gt;setMaxResults($max_result);
                                $results = $q-&gt;getResult();
  </code></pre>
  
  <p>Here rank is the variable i am trying to set</p>
  
  <p>problem im facing</p>
  
  <ul>
  <li>im unable to set  variable in dql .</li>
  </ul>
  
  <p>errorlog</p>
  
  <pre><code> PHP Fatal error:  Uncaught exception 'Doctrine\\ORM\\Query\\QueryException' with message 'select distinct u.id, u.city,u.country,u.designation FROM Entities\\User u JOIN Entities\\EventVisitor evt_vstr WITH evt_vstr.user = u.id \n\t \t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\tCASE\n\t\t\t\t\t\t\t\t\t\t\t\tWHEN Co-founder =u.designation THEN SET @rank=1\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tEND   ) ' in /home/india/public_html/serve-trade-com/application/libraries/Doctrine/ORM/Query/QueryException.php:39\nStack
  </code></pre>
  
  <p>But its not working.</p>
  
  <p>How can i do that ?</p>
  
  <p>OR is there any way to do that</p>
  
  <p>Please help</p>