We are converting an application for use with CakePHP 2.0.3. For some
reason, I cannot seem to set proper relations between my models.

Here's an example:

User (id, petid, country, picid, ...)
Pet (id, userid, picid, ...)
Picture (id, albumid, ....)
Album (id, userid, petid, ...)
The meanings of these are the following: - A user can have multiple
pets, but can only have selected one pet at the same time (therefore,
petid in User)

- Pets belong to one user

- Pets and Users can have multiple pictures, but only one profile
picture, therefore Pet.picid and User.picid

- Pets and users can have multiple Albums


I set up my models in CakePHP, but I cannot figure out which relations
to use between them since the Database is not following the
conventions. I've tried the following:

User
-> hasMany(Pets)
-> hasOne(Picture)
-> hasMany(Album)

Pet
-> belongsTo(User) (works fine, with foreignkey userid)
-> hasMany(Album)
-> hasOne(Picture)

Album
-> hasMany(Picture)

---- Logic to achieve this? It either belongs to a user or pet-----

-> belongsTo(User)
-> belongsTo(Pet)

Picture
-> belongsTo(Album)
I'm new to CakePHP and cannot figure out the way to go here. Do you
have any suggestions?

Thanks

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to