Welcome Guest, Not a member yet? Register   Sign In
Datamapper advanced relationship question
#2

[eluser]WanWizard[/eluser]
With 'children' you mean values?

Assuming that you have a model Location, and a model Sublocation, and a one-to-many relation between the two, you use
Code:
// get the 'cavern' location
$location = new Location();
$location->get_by_name('Cavern');

// get all sublocations
$location->sublocation->get();

// print them
echo $location->name, '<br />';
foreach ($location->sublocation as $sl)
{
    echo $sl->type, $sl->name, '<br />';
}

Start reading here, and then use the 'next topic' link in the footer to go to the next page. It will explain how relations are defined, and how you access them.


Messages In This Thread
Datamapper advanced relationship question - by El Forum - 05-15-2012, 10:02 AM
Datamapper advanced relationship question - by El Forum - 05-15-2012, 11:20 AM
Datamapper advanced relationship question - by El Forum - 05-15-2012, 01:21 PM
Datamapper advanced relationship question - by El Forum - 05-15-2012, 02:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB