• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Datamapper advanced relationship question

#1
[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


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.