title: CakePHP model saving to wrong table
body: <p>In my User model I have the following relationship:</p>
  
  <pre><code>public $hasAndBelongsToMany = array(
          'User'=&gt;array(
              'className'              =&gt; 'User',
              'joinTable'              =&gt; 'friends',
              'with'                   =&gt; 'Friend',
              'foreignKey'             =&gt; 'user_id',
              'associationForeignKey'  =&gt; 'friend_id'
          )
  );
  </code></pre>
  
  <p>Which links users to users as friends. However when I do something with a single user like change the password or edit the user details (unrelated to the friends), it will start doing stuff in the friends table such as delete all existing records and then add in empty rows of data...</p>
  
  <p>Have I set the relationship up wrong? Should the naming be different, so that when I'm dealing with the <code>$this-&gt;User</code> it is not touching friends?</p>
  
  <p><strong>Edit: Since posting this question I have changed the user_id and friend_id to user1_id and user2_id to prevent Cake doing any automagic with the fields by assuming that they are primary keys or anything as explained below by nIcO. But the same problem still happens!</strong></p>