I also have this situation: User who created an item and those who are officially responsible for the item. Both coming from the same user table.
What I did is ( no genius solution, but it works):
E.g. when adding an item:
$responsible = $this->Vertrag->User->find('list');
In the database I have the field "responsible" which saves the user id.
It works but isn't an elegant solution, becuase I don't user the full Cake power and have to do the rest manually.
Anja
-----Ursprüngliche Nachricht-----
Von: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] Im Auftrag von sjunwanted@gmail.com
Gesendet: Sonntag, 1. März 2009 11:12
An: CakePHP
Betreff: 2 foreign keys to same model?
Hi,
using cake1.2,
I came across a problem while setting up my database.
I have a question on how to set this database up by cake's convention.
I have the following 2 tables:
users
assets
each user has many assets, but any users can allow other users to access their assets so I figure the following, a third table is needed:
a table that has attributes:
owner, allowed
they both point to users_id, how do I make this table model in cakephp? Is there another way to do this?
Because i know users_id means foreign key to table users, but how do you have 2 foreign to the same table?
in short
users has many assets, any users can access other user's assets as long as their id are on the allowed attribute of the owner id. both columns points to the users table
thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment