I have not tried doing this before but if I were to try I would first
create duplicate model classes for the models needing a different
primary key defined.  There should be no reason why two model classes
point to the same db table except that it seems weird.

class ContactEmail extends AppModel {
  var $tableName = 'contacts';
  var $primaryKey = 'emailAddress';

  var $belongTo = ...
}

And override the various fields as needed and ditto for the
MailMessage if needed.

YMMV ....

David Lloyd
--
lloydhome consulting
http://lloydhome.com

On Feb 11, 2:05 pm, "Dan" <[EMAIL PROTECTED]> wrote:
> Hi
>
> developing a very simple webmail app in cake and am having trouble
> with the association between the MailMessage model and it's related
> sender's Contact model.
>
> I want to relate the MailMessage as 'belongsTo' Contact via the
> MailMessage and Contacts email field - only I can't seem to work out
> how to do it, as it's automagically assuming that the field on the
> Contact model is Contact.id.
>
> Can I override the primary key as follows?
>
> MailMessage.fromAddress = Contact.emailAddress
>
> I suspect, I've not fully understood associations and that there is a
> much more striaghtforward way to do this :)
>
> Many thanks
>
> D


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to