Welcome Guest, Not a member yet? Register   Sign In
DataMapper multiple self relations
#1

[eluser]TomMRiddle[/eluser]
I am trying to understand how to make datamapper use the following relationship for movies, tvseries, seasons and episodes:
[Image: database.png]

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);
    }
}

?>


Messages In This Thread
DataMapper multiple self relations - by El Forum - 02-07-2011, 06:55 AM
DataMapper multiple self relations - by El Forum - 02-08-2011, 09:30 AM
DataMapper multiple self relations - by El Forum - 02-09-2011, 07:35 AM
DataMapper multiple self relations - by El Forum - 02-09-2011, 02:24 PM
DataMapper multiple self relations - by El Forum - 02-10-2011, 05:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB