I’m setting up relationships in my models using DataMapper but I’ve hit a wall.
I have a RealEstate class, a Client class and a Position class which all have many to many relationships.
Clientcan have thePosition‘buyer’ in aRealEstate- Same
Clientcan have thePosition‘seller’ in anotherRealEstate
So for a given RealEstate it’s easy to find all the Clientss attached to it, but how can I also include what Position those clients have for the specific RealEstate?
I think you have an incorrect design for it. It really should be many-to-many relationship between
ClientandPosition, but only one-to-many relationship betweenPositionandRealEstate, with one onRealEstateside. It effectively emulates many-to-many relationship betweenRealEstateandClientthat have an additional info (Position) in it.Speaking in terms of problem domain, any role (
Position) is attached to specificRealEstate, but anyClientcan have arbitrary number of roles and anyRealEstatecan(?) have multiple roles attached to it.I don’t have CodeIgniter 2 at fingertips, so can’t provide code samples, but let me know if you really need it – I have it CodeIgniter 2 at home.