Hi there, well, this is a very basic question and I hope someone is able to help me with this.
Given is a three level association like User -> hasOne Profile -> hasMany ProfileAttachment My problem with this is to make sure a user does not save foreign ProfileAttachments. Saving the profile is no problem, I can simply check if the currently logged in user id is the same as the one from the existing profile. But when saving a ProfileAttachment this one does have a direct association to Profile but not to User, as the one to User is generated automatically in line. That's a good way of trimming the database, but when simply saving the attachment I have to check against the profile_id _and_ user_id which is not defined in ProfileAttachment but in Profile. So to check against the user_id too I assume I have to fetch the profile within my save() function to find out which user the profile with the given profile_id belongs to. That's what I dislike - is there a way to check against the "parent" model's fieldName without querying it manually? Well, the more I read my own text here the more it seems I have to fetch it, no way out. But maybe there's someone who knows a better, more automatic, way. :-) I was thinking about associating the ProfileAttachment as belongsTo User too, but that would be some overhead in database normalization, I think. Best regards, Arne --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
