Hi gribelu What you need to do is create two new models for the countries table:
location.php nationality.php These models will both use the countries table, and can, if you choose have a hasMany relationship to Profile. Then in your Profile model, you have two belongsTo relationships, one to each of the new models above. In the Profiles table you need to rename your foreign key fields: location_id nationality_id This should do the trick, and Cake will do all of the heavy lifting for you. No queries to write. I recommend that you read up in the manual about belongsTo relationships and using tables with different names in a model. That should fill in the details that I have not included here. Regards, Langdon > I'm currently building the front page for an application. On this page > there's a list of users with some of their profile data. > > The model looks kinda like this: "User hasOne Profile" > > In the 'profiles' table i have two fields 'location' and 'nationality' > wich both point to id's from the "countries" table. What i want is to > get the country_name from that table and use it in my view. > Using multiple "Profile hasOne Country" doesn't work (duh).. If i use > multiple "Country belongsTo Profile" almost works but it doesn't use > joins and it's just plain wrong for what i need. > > Is there a way to make this work without writting the entire query by > hand? Also, i don't want multiple queries per user.. that would be bad > for performance. > > Thank you --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
