title: Create custom DQL like IF MySQL Function but it doesn't work - [Symfony 2]
body: <p>I intend to add IfFunction to DQL but it doesn't work :</p>
  
  <pre><code>//My DQL Class
  &lt;?php
  
  namespace Application\HappyBundle\DQL;
  
  use Doctrine\ORM\Query\AST\Functions\FunctionNode;
  use Doctrine\ORM\Query\SqlWalker;
  use Doctrine\ORM\Query\Parser;
  use Doctrine\ORM\Query\Lexer;
  
  /**
   * IFFunction ::= "IF" "( "ArithmeticPrimary" , "ArithmeticPrimary" ,  "ArithmeticPrimary" )"
   */
  class IFFunction extends FunctionNode
  {
      // (1)
      public $firstNumericExpression = null;
      public $secondNumericExpression = null;
      public $thirdNumericExpression = null;
  
      public function parse(\Doctrine\ORM\Query\Parser $parser)
      {
  
          $parser-&gt;match(Lexer::T_IDENTIFIER); // (2)
          $parser-&gt;match(Lexer::T_OPEN_PARENTHESIS); // (3)
          $this-&gt;firstNumericExpression = $parser-&gt;ArithmeticPrimary(); // (4)
          $parser-&gt;match(Lexer::T_COMMA); // (5)
          $this-&gt;secondNumericExpression = $parser-&gt;ArithmeticPrimary(); // (6)
          $parser-&gt;match(Lexer::T_COMMA); // (5)
          //$parser-&gt;match(Lexer::T_CLOSE_PARENTHESIS); // (3)
          $this-&gt;thirdNumericExpression = $parser-&gt;ArithmeticPrimary(); // (6)
          $parser-&gt;match(Lexer::T_CLOSE_PARENTHESIS); // (3)
  
      }
  
      public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
      {
          return 'IF(' .
              $this-&gt;firstNumericExpression-&gt;dispatch($sqlWalker) . ', ' .
              $this-&gt;secondNumericExpression-&gt;dispatch($sqlWalker) . ', ' .
              $this-&gt;thirdNumericExpression-&gt;dispatch($sqlWalker) .
          ')';
      }
  }
  </code></pre>
  
  <p>//Déclaration in config.yml</p>
  
  <pre><code>        dql:
              datetime_functions:
                  timediff: Application\HappyBundle\DQL\TimeDiff  
                  addtime: Application\HappyBundle\DQL\AddTime    
              numeric_functions:
                  IF: Application\HappyBundle\DQL\IFFunction            
  </code></pre>
  
  <p>The add of the DQL function work, but when i intend to do for exemple :</p>
  
  <pre><code>SELECT IF(1&lt;2,'oui','non');
  </code></pre>
  
  <p>There is an error on char '&lt;'
  If i put the If function like this </p>
  
  <pre><code>SELECT IF('1&lt;2','oui','non');
  </code></pre>
  
  <p>It's work but is not evaluate the first condition :( </p>
  
  <p>If someone have got an idea ...
  Thx for your help.</p>