title: ActiveRecord - associating foreign keys with different naming conventions?
body: <p>I am working on a private messaging system using PHP-ActiveRecord ORM. I have models called 'User' and 'Message', MySQL tables called 'users' and 'messages', and in the messages table, I have fields called 'sender_id' and 'recipient_id'. However, I have no idea how to properly associate senders and recipients to the User model.</p>
  
  <p>This is what I have so far in the User model:</p>
  
  <pre><code>static $has_many = array(
      array('messages'),
      array('recipients', 'foreign_key' =&gt; 'recipient_id', 'class_name' =&gt; 'Message'),
      array('senders', 'foreign_key' =&gt; 'sender_id', 'class_name' =&gt; 'Message'),
  );
  </code></pre>
  
  <p>and this is what I have so far in the Message model:</p>
  
  <pre><code>static $belongs_to = array(
      array('sender', 'class_name' =&gt; 'User'),
      array('recipient', 'class_name' =&gt; 'User'),
  );
  </code></pre>
  
  <p>However, when I run the code such as $message->recipient->first_name, it does not properly pull the first name from the User model, like I want it to. I am not sure what I am doing wrong.</p>
  
  <p>Normally, I just use the standard naming conventions. However, for this example, we have to have sender_id and recipient_id, which are both the same type, so I can't just use the standard naming conventions as I have been doing.</p>
  
  <p>Any help would be highly appreciated. I am using the PHP-ActiveRecord ORM. I think the Rails version is more widely used, but it is my understanding that they work the same except with different syntax.</p>