Reputation: 1733
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.
Client
can have the Position
‘buyer’ in a RealEstate
Client
can have the Position
‘seller’ in another RealEstate
So for a given RealEstate
it’s easy to find all the Clients
s attached to it, but how can I also include what Position
those clients have for the specific RealEstate
?
Upvotes: 0
Views: 477
Reputation: 26941
I think you have an incorrect design for it. It really should be many-to-many relationship between Client
and Position
, but only one-to-many relationship between Position
and RealEstate
, with one on RealEstate
side. It effectively emulates many-to-many relationship between RealEstate
and Client
that have an additional info (Position
) in it.
Speaking in terms of problem domain, any role (Position
) is attached to specific RealEstate
, but any Client
can have arbitrary number of roles and any RealEstate
can(?) 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.
Upvotes: 1