title: Converting MySQL to Doctrine Query Builder. Issues with IF and CONCAT. Or another approach for subqueries on select
body: <p>I have a table for my categories, each category have and id, name and parent_id.</p>
  
  <pre><code>Select IF(a.parent_id IS NULL, a.name, CONCAT((SELECT b.name FROM category b WHERE b.id = a.parent_id), " / ", a.name) ) as n, a.id, a.parent_id
  FROM category a
  ORDER BY n
  </code></pre>
  
  <p>I want to convert it to my Doctrine2 Query Builder</p>
  
  <pre><code>    $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
      $qb = $em-&gt;createQueryBuilder();
      $q = $qb
              -&gt;select("c.id")
              -&gt;addSelect(
                  "IF(c.parent_id IS NULL, c.name, CONCAT((" .
                  $em-&gt;createQueryBuilder()
                     -&gt;select("t.name")
                     -&gt;from("MyBundle:Category", "t")
                     -&gt;getQuery()-&gt;getDQL() .
                  "), \" / \", c.name) )"
              )
              -&gt;from("MyBundle:Category", "c");
      echo $q-&gt;getQuery()-&gt;getSQL();
      exit;
  </code></pre>
  
  <p>Something like that, but I cant use the <code>IF</code>, and <code>CONCAT</code>.</p>