Animal belongsTo User would not work because that would require that the animals table had a column user_id. But that would limit each Animal to a single User.
User hasOne Animal Animal hasMany User So, nothing special in animals table but users gets an animal_id column. On Sat, Jul 25, 2009 at 7:38 AM, majna<[email protected]> wrote: > > User hasOne Animal > Animal belogsTo User > > Fore select option: > > contoller > (if animals table has title or name) > $this->set('animals', $this->User->Animal->find('list'); > > view > echo $form->select('animal_id',$animals) > > > > On Jul 25, 5:39 am, Sarah <[email protected]> wrote: >> I am not sure how to define the relationship between two tables: users >> and animals. >> >> Animals is a list of animals >> Each user in the user table has one animal >> More than one user can have the same animal >> >> I'm not sure if this is technically a hasMany relationship (since I >> suppose you could say that an animal has several users, although the >> user is not an attribute of an animal, an animal is an attribute of a >> user). >> >> In my user registration form I would like to have a select option for >> users to choose an animal (from the table). >> >> Should I define a hasMany relationship in my Animal model? If so what >> steps should I take to incorporate the animals into my user form? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
