[eluser]WanWizard[/eluser]
Ok, I've ran some tests.
I've created the tables "ones", "twoes" (this is what datamapper does by default!), "threes" and "ones_twoes":
Code:
The model One:
- has_one to one_two
- has_many to two and three
The model Two:
- has_many to one
The model Three:
- has_many to one and one_two
The model One_two:
- has_one to one, two and three
With this setup, I can do:
Code:
// simple one-to-many
$one = new One(1);
$one->three->get();
// access three via the relationship table
$one_two = new One_two(1);
$one_two->three->get();
// get the relationship directly
$one->one_two->get();
// get three via the one_two relationship table
$one->one_two->three->get();
So yes, you can use the three_id in the relationship table between one and two if you define one_two as a model with the proper relationship definitions.
Datamapper doesn't care how crazy you make it, al long as the relationships are defined properly, and the correct tables (and id fields) are there. You can even create a many to many between ones_twoes and fives_sixes with would create a relationship table called one_twoes_fives_sixes!