title: How to add LIKE expression in QueryBuilder for a column without alias
body: <p>I am developing a list with filter in Yii1 and doctrine2.
  I will skip unnecessary information like controller-action codes and just explain the problem.</p>
  
  <p>This is my queryBuilder object:</p>
  
  <pre><code>$queryBuilder = $this-&gt;createQueryBuilder('asset')
              -&gt;select("asset.id, 
                  CONCAT(user.firstName, CONCAT(' ',user.lastName)) assignedBy, 
                  asset.createdAt, asset.serial, asset.brand, asset.model,
                  assetType.name assetTypeName, 
                  CONCAT(assigned.firstName,CONCAT(' ',assigned.lastName)) assignedTo, 
                  asset.status, location.name locationName")
              -&gt;leftJoin('asset.user', 'user')
              -&gt;leftJoin('asset.assigned', 'assigned')
              -&gt;leftJoin('asset.location', 'location')
              -&gt;leftJoin('asset.assetType', 'assetType');
  </code></pre>
  
  <p>As you may noticed, I have two aggregated columns(assignedBy, AssignedTo) without alias(If I could, I would write <strong>user.assignedBy</strong> in the first one and same for the later one, <strong>but</strong> it is not acceptable in sql since they do not belong to any actual table).</p>
  
  <p>Later on, when form submitted in client, I need to add like expressions for them. (It is kind of auto generated query, but for simplification I will mention the function in charge of it only and skip the rest)
  this function works with an array from $_REQUEST. I put it here as guide:</p>
  
  <pre><code>array (size=9)
    'assignedBy' =&gt; string 'mojtaba' (length=7)
    'createdAt' =&gt; string '' (length=0)
    'serial' =&gt; string '' (length=0)
    'brand' =&gt; string '' (length=0)
    'model' =&gt; string '' (length=0)
    'assetType' =&gt; string '' (length=0)
    'assigned' =&gt; string '' (length=0)
    'location' =&gt; string '' (length=0)
    'status' =&gt; string '' (length=0)
  </code></pre>
  
  <p>and the function:</p>
  
  <pre><code>    /**
       * @return $this
       * @throws \CException
       */
      public function applyFilter()
      {
          // it is the array came from $_REQUEST, I mentioned it above.
          if (isset($_REQUEST[$this-&gt;getFilterKey()])) {
              $or = $this-&gt;getQueryBuilder()-&gt;expr()-&gt;orX();
  
              foreach ($_REQUEST[$this-&gt;getFilterKey()] as $key =&gt; $val) {
                  if ($val) {
                      $term = $key;
                      $or-&gt;add($this-&gt;getQueryBuilder()-&gt;expr()-&gt;like($term, ":" . $key));
                      $this-&gt;getQueryBuilder()-&gt;setParameters(array($key =&gt; "%" . $val . "%"));
                  }
              }
              ($or-&gt;getParts()) ? $this-&gt;getQueryBuilder()-&gt;andWhere($or) : "";
          }
          return $this;
      }
  </code></pre>
  
  <p>for all the columns with alias in this query, there is absolutely no problem but for these two, I get this error:</p>
  
  <pre><code>[Syntax Error] line 0, col 186: Error: Expected '.' or '(', got 'assignedBy'
  </code></pre>
  
  <p>and the real error occurs in here:</p>
  
  <pre><code>vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(2541): Doctrine\ORM\Query\Parser-&gt;LikeExpression()  
  </code></pre>
  
  <p>I have read that QueryBuilder does not support functions in Like expression here:
  <a href="https://stackoverflow.com/questions/10916797/doctrine-query-like-expression">Doctrine query + LIKE expression</a>, but It is a different matter, I do not need to use functions, I want to use a column without alias in queryBuilder alias expression and I get this error, any help will be appreciated.</p>