[eluser]Haskabab[/eluser]
Hey,
If i post this in the wrong forum, I'm sorry for that. I wasn't sure where to post this.
But I've been using DataMapper ORM and I'm loving it so far. Now I've run into a problem: I don't know how to setup relationships for the following db tables:
Location -- (contains coordinates of the location)
This location can have several children: 'Village' or 'Hideout' or 'Cavern'.
Within this
Location there can be several
Sublocations (one-to-many)
This sublocation again, can have several children: 'Shop' or 'Hospital'
Normally I would add the fields 'type' and 'db_id' and write a function 'getChild()' to get the child depending on the type. But how do I do this in datamapper?
To get something like:
Code:
$location->child->name
or
Code:
$location->sublocations
Code:
foreach( $sublocations as $sublocation ){ echo $sublocation->type.': '.$sublocation->child->name
I've searched the documentation but I didn't find anything related to this. So if you know how to do this, I would really appreciate it if you told me!
Thanks in advance,
Nick