title: how to pass variables to Orderby Clause using Doctrine
body: <p>I am getting an error while trying to achieve dynamic sorting in DQL's <code>ORDER BY</code> clause with Doctrine 2 ORM.</p>
  
  <p>Here is my code snippet:</p>
  
  <pre class="lang-php prettyprint-override"><code>$queryBuilder = $categoryEntity-&gt;createQueryBuilder('category');
  
  $queryBuilder-&gt;distinct();
  $queryBuilder-&gt;join('Category\Entity\CategoryName', 'category_name', 'WITH', 'category.id = category_name.category');
  
  
  if($column == 'status'){
      $queryBuilder-&gt;orderBy("category.status $order");
  }else{
      $queryBuilder-&gt;orderBy("category_name.name $order");
  }
  </code></pre>
  
  <p>This produces the following error:</p>
  
  <blockquote>
    <p>[Syntax Error] line 0, col 189: Error: Expected end of string, got 'ASC'</p>
  </blockquote>