[eluser]rayray[/eluser]
I'm looking to possibly migrate from IgnitedRecord over to DataMapper. My schema has one funky thing that I can't quite get to work properly in DMZ. I have 2 tables: users and events. Users has_many events and events has_many users. No problem here. But users can be associated with an event as a user, administrator, or both. In IgnitedRecord, to solve this by creating 2 join tables, one named 'events_users' and the other 'administrators_events'. IgnitedRecord allows you to specify a name for the relationship and the name of the join table for that relationship. The relationship looked like this:
Code:
Class User extends IgnitedRecord{
public $has_and_belongs_to_many = array(
array('table'=>'events', 'name'=>'admin_events', 'join_table'=>'administrators_events'),
array('table'=>'events', 'name'=>'events', 'join_table'=>'events_users'));
}
Class Event extends IgnitedRecord{
public $has_and_belongs_to_many = array(
array('table'=>'users', 'name'=>'administrators', 'join_table'=>'administrators_events'),
array('table'=>'users', 'name'=>'users', 'join_table'=>'events_users'));
}
To access the relationship in IR you'd do something like: