It really wouldn't be a has one though.  What if a counselor goes on vacation, dies, quits, etc...  A client could still have many counselors (just usually the same one).  A counselor would have many clients.  And they both could have many appointments.

I think you are going to need some join tables here.

Maybe someone has a better solution?

On 6/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

I have an interesting situation:

I have a Model Appointment as follows:

id
client_id
counselor_id
start_time
end_time

I have a Model Client as follows

id
firstname
lastname

I have a Model Counselor as follows:

id
firstname
lastname

I want to do a Appointment->findById() and get all the associated data,
but you will notice that the simple hasOne doesn't work.

How would I set up relationships to do this? I tried

var $hasOne = array('Client' =>
                        array('className'    => 'Client',
                              'conditions'   => '',
                              'order'        => '',
                              'dependent'    =>  true,
                              'foreignKey'   => 'client_id'
                                ),
                                'Counselor' =>
                                        array('className'    => 'Counselor',
                                                      'conditions'   => '',
                                                      'order'        => '',
                                                      'dependent'    =>  true,
                                                      'foreignKey'   => 'counselor_id'
                                )
                  );

but that tries to join Client.client_id = Appointment.id

It seems this is sort of a "reverse has one" type of setting, if that
makes sense, but I can't wrap my head around how to do this.

Brian




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

Reply via email to