title: CakePHP JOINS Query
body: <p>I was following a tutorial <a href="http://www.studiocanaria.com/articles/cakephp_auth_component_users_groups_permissions" rel="nofollow">about permissions</a> instead CakePHP.
  I don't understand how this model (query) works.</p>
  
  <p>Can anybody explain me how this query works.. I can't find what this variable <strong>hasAndBelongsToMany</strong> exactly does.</p>
  
  <pre><code>&lt;?php
  class Group extends Appmodel {
      var $name = 'Group';
      var $useTable 'groups';
      var $hasAndBelongsToMany = array(
      'Permission' =&gt; array('className' =&gt; 'Permission',
                      'joinTable' =&gt; 'groups_permissions',
                      'foreignKey' =&gt; 'group_id',
                      'associationForeignKey' =&gt; 'permission_id',
                      'unique' =&gt; true
                      )
      'User' =&gt; array('className' =&gt; 'User',
                      'joinTable' =&gt; 'groups_users',
                      'foreignKey' =&gt; 'group_id',
                      'associationForeignKey' =&gt; 'user_id',
                      'unique' =&gt; true
                      ),  
                  );
  }
  </code></pre>