[eluser]TomMRiddle[/eluser]
I am trying to understand how to make datamapper use the following relationship for movies, tvseries, seasons and episodes:
1. I don't know how to make it use the type column for it to know what type it is and what it relates to.
2. How do I go about accessing child/parent objects in the controller when I only have one model.
Movie model:
Code:
<?php
class Movie extends DataMapper {
var $has_many = array(
'job' => array(),
'comment' => array(),
'tvseries' => array(
'class' => 'movie',
'other_field' => 'season',
'join_table' => 'seasons_tvseries',
'reciprocal' => TRUE
),
'season' => array(
'class' => 'movie',
'other_field' => 'episode',
'join_table' => 'episodes_seasons',
'reciprocal' => TRUE
),
);
var $has_one = array(
'season' => array(
'other_field' => 'tvseries',
),
'episode' => array(
'other_field' => 'season',
)
);
//var $has_many = array('mymovie');
//var $has_one = array('subscribed');
function __construct($id = NULL)
{
parent::__construct($id);
}
}
?>