One-to-many and one-to-one relationships between the same two tables...

2008-02-18 Thread dasn

I have a situation that I'm not sure how to build the cake model
relationships for.

I have two tables, Companies and Contacts.  A Company can have many
contacts but it also has one primary contact.  I figured I would set
up hasMany and belongsTo entries for the Company and Contact models.
But how do I set up the secondary link?  I have the Contacts table set
up with a company_id field to relate it to the company table. I think
I should create a field in the Company table called
primary_contact_id but I'm not sure how to set up the model
relationships.

Thanks in advance!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: One-to-many and one-to-one relationships between the same two tables...

2008-02-18 Thread AD7six



On Feb 18, 5:26 am, dasn [EMAIL PROTECTED] wrote:
 I have a situation that I'm not sure how to build the cake model
 relationships for.

 I have two tables, Companies and Contacts.  A Company can have many
 contacts but it also has one primary contact.  I figured I would set
 up hasMany and belongsTo entries for the Company and Contact models.
 But how do I set up the secondary link?  I have the Contacts table set
 up with a company_id field to relate it to the company table. I think
 I should create a field in the Company table called
 primary_contact_id but I'm not sure how to set up the model
 relationships.

 Thanks in advance!

http://groups.google.com/group/cake-php/browse_frm/thread/9fe64a3f64027807/60ce8ba56eb2429b
(don't only read my opinion in that thread)

hth,

AD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---