// in class User
$has_many = array(
'sent_message' => array(
'class' => 'message'
'other_field' => 'from_user'
),
'received_message' => array(
'class' => 'message'
'other_field' => 'to_user'
)
);
// in class message
$has_one = array(
'from_user' => array(
'class' => 'user'
'other_field' => 'sent_message'
),
// this could instead be in the has_many, if you prefer
'to_user' => array(
'class' => 'user'
'other_field' => 'received_message'
)
);
// usage
$user->save_received_message($message);
$message->save_from_user($user);
// etc., there are plenty of examples of this