I have this problem when I create phps with cake bake In cakephp.I have the following problem: if I keep two elements in libraries, one with id 1 and othe id 2.then I saved an item in rooms with library_id= 1,and after another item in rooms with library_id= 2. I really can relate room element with the element of user. This should not afford it since they have the same library_id.So it does not refer to the same library. I need only user can relate to room if they refer to the same library.I try that cakephp throws error, or do not allow the relationship, when users and rooms not have the same library_id,how I can do this?
result tables:
libraries users rooms users_rooms
id id library_id id library_id user_id room_id
1 1 1 1 2 1 1
2