You would break the rules of database normalisation if you linked the
users to the company. You would be duplicating data.
thought so!
Note: Breaking the rules of database normalisation will not condemn
your soul to an eternity in the pit - sometimes the real world gets in
the way of a perfect ideal.
An alternative model would be:
Company hasMany Users
Branches hasMany Users
and Branch belongsTo Company (without that, there's no correlation
Company and Branch)
If I go with:
Company hasMany Branch
Branch hasMany User
Branch belongsTo Company
User belongsTo Branch
If I do that - what;'s the best way to get all the users in a company
? If I could get the list of branch IDs for a company, is it possible
to pass an array of possible 'branch_id's in the find, like:
// find Branch IDs
$branch_ids = $this->Company->Branch->findAll
(array("Branch.company_id" => $company_id), "Branch.id");
// find all users that match
$users = $this->Company->Branch->User->findAll (array("User.branch_id"
=> $branch_ids));
would that work?
thanks
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---