title: How to use phalcon createbuilder for join multiple tables
body: <p>here is the working code for displaying rows from 3 different tables using <strong>PHQL</strong>. i want to code the same using <code>$this-&gt;modelsManager-&gt;createBuilder()</code>. Please find working code and error below.</p>
  
  <p>Controller</p>
  
  <pre><code>&lt;?php
      $phql  = 'SELECT product.*, currency.*, unittype.* FROM product LEFT JOIN currency ON product.CurrencyId=currency.Id LEFT JOIN unittype ON product.UnitTypeId=unittype.Id ORDER BY product.Name ASC';
      $query = $this-&gt;modelsManager-&gt;createQuery($phql);
      $this-&gt;view-&gt;products = $query-&gt;execute();
  ?&gt;
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
          &lt;th&gt;Unit Type&lt;/th&gt;
          &lt;th&gt;Price&lt;/th&gt;
          &lt;th&gt;Currency&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;?php foreach($products as $row)    { ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $row-&gt;product-&gt;Name; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row-&gt;product-&gt;Description; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row-&gt;unittype-&gt;Name; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row-&gt;product-&gt;Price; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row-&gt;currency-&gt;Code; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $this-&gt;tag-&gt;linkTo('product/edit/'.$row-&gt;product-&gt;Id,'Edit'); ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $this-&gt;tag-&gt;linkTo('product/delete/'.$row-&gt;product-&gt;Id,'Delete'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php } ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <blockquote>
    <p>I wanted to use createbuilder from modelmanager; how to writequery and
    print in view?</p>
    
    <p>below is the code i wrote and having issue:</p>
  </blockquote>
  
  <p>Controller</p>
  
  <pre><code>&lt;?php
      $this-&gt;view-&gt;products = $this-&gt;modelsManager-&gt;createBuilder()
          -&gt;from('product')
          -&gt;innerjoin('currency','product.CurrencyId=currency.Id')
          -&gt;orderBy('product.Name')
          -&gt;getQuery()
          -&gt;execute();
  ?&gt;
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Description&lt;/th&gt;
          &lt;th&gt;Unit Type&lt;/th&gt;
          &lt;th&gt;Price&lt;/th&gt;
          &lt;th&gt;Currency&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;?php foreach($products as $product)    { ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $product-&gt;Name; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $product-&gt;Description; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $product-&gt;UnitTypeId; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $product-&gt;Price; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $product-&gt;currency-&gt;Id; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $this-&gt;tag-&gt;linkTo('product/edit/'.$product-&gt;Id,'Edit'); ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $this-&gt;tag-&gt;linkTo('product/delete/'.$product-&gt;Id,'Delete'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php } ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong><em>Above code producing following error:</em></strong></p>
  
  <blockquote>
    <p>Notice: Trying to get property of non-object in
    C:\wamp\www\xxxx.volt.php on line xx</p>
  </blockquote>