I'm having this problem with relationships with Codeigniter's DataMapper.
I have an Interview
model that has an author_id
and an interviewee_id
. They both relate to the user id in the user model.
I've been trying several approaches and none work; this is what I have right now:
class Interview extends DataMapper
{
var $has_one = array(
'interviewee' => array(
'class' => 'user',
'other_field' => 'done_interview'),
'author' => array(
'class' => 'user',
'other_field' => 'written_interview')
);
}
class User extends DataMapper
{
var $has_many = array(
'done_interview' => array(
'class' => 'interview',
'other_field' => 'interviewee'),
'written_interview' => array(
'class' => 'interview',
'other_field' => 'author')
);
}
How do I let DataMapper know that one relationship will go through author_id
, and the other through interviewee_id
?