title: Phalcon php orm can't relate tables
body: <p>I'm trying to setup a 3 tables relationship in phalcon, but it doesn't seem to work. Could anyone plese tell me what am I doing wrong? Here is a ERD of these tables: <a href="http://tinypic.com/view.php?pic=k4h4ee&amp;s=8#.U1D_6Pl_s1M" rel="nofollow">(ERD diagram)</a> Here is my code from models and controller</p>
  
  <pre><code>Authors.php (Model)
  
  &lt;?php
  
  
  
  
  class Authors extends \Phalcon\Mvc\Model
  {
  
  /**
  *
   * @var integer
  */
  public $ID;
  
  /**
  *
  * @var string
  */
  public $Name;
  
  /**
  *
  * @var string
  */
  public $LastName;
  
  /**
  * Initialize method for model.
  */
  public function initialize()
  {
    $this-&gt;setSource('Authors');
    $this-&gt;hasMany('ID', 'Authorbook', 'AuthorID');
  }
  
  /**
  * Independent Column Mapping.
  */
  public function columnMap()
  {
    return array(
        'ID' =&gt; 'ID', 
        'Name' =&gt; 'Name', 
        'LastName' =&gt; 'LastName'
    );
  }
  </code></pre>
  
  <p>Books.php(Model)</p>
  
  <pre><code>&lt;?php
  
  
  
  
  class Books extends \Phalcon\Mvc\Model
  {
  
   /**
    *
    * @var integer
    */
   public $ID;
  
   /**
    *
    * @var string
    */
   public $Name;
  
   /**
    *
    * @var string
    */
   public $YearPublished;
  
   /**
   *
   * @var string
   */
   public $Picture;
  
  /**
   * Initialize method for model.
   */
  public function initialize()
  {
      $this-&gt;setSource('Books');
      $this-&gt;hasMany('ID', 'Authorbook', 'BookID');
  }
  
  /**
   * Independent Column Mapping.
   */
   public function columnMap()
   {
       return array(
          'ID' =&gt; 'ID', 
          'Name' =&gt; 'Name', 
          'YearPublished' =&gt; 'YearPublished', 
          'Picture' =&gt; 'Picture'
      );
   }
  
   }
  
  }
  </code></pre>
  
  <p>AuthorBook.php (Model):</p>
  
  <pre><code>&lt;?php
   class Authorbook extends \Phalcon\Mvc\Model
   {
  
   /**
     *
    * @var integer
    */
   public $ID;
  
   /**
    *
    * @var integer
   */
  public $AuthorID;
  
  /**
   *
   * @var integer
   */
  public $BookID;
  
  /**
  * Initialize method for model.
  */
  public function initialize()
  {
    $this-&gt;setSource('AuthorBook');
    $this-&gt;belongsTo('AuthorID', 'Authors', 'ID');
    $this-&gt;belongsTo('BookID', 'Books', 'ID');
  }
  
   /**
   *   Independent Column Mapping.
   */
  public function columnMap()
  {
  return array(
      'ID' =&gt; 'ID', 
      'AuthorID' =&gt; 'AuthorID', 
      'BookID' =&gt; 'BookID'
  );
  }
  
  }
  </code></pre>
  
  <p>AdminController.php</p>
  
  <pre><code>public function indexAction()
  {
      $this-&gt;view-&gt;disableLevel(View::LEVEL_MAIN_LAYOUT);
      $this-&gt;view-&gt;setVar('books', Books::find()-&gt;toArray());
  }
  
  }
  </code></pre>
  
  <p>So my question is how can I get access to the author of a book? Because when I print out my books array in view only thing I get is :</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
  (
      [ID] =&gt; 1
      [Name] =&gt; Javascript: The Good Parts
      [YearPublished] =&gt; 2014-04-18
      [Picture] =&gt; javascript-the-good-parts.jpg
  )
  ...
  </code></pre>