Yes, I am either going to have to do that, or come at it from the
Client viewpoint, so that a Client has many Appiontments, so I can get
a Client with all appointments or with one specific appointment.

Then I think I have to get the Counselor in a second step.

There are several ways to look at it from a design perspective, I'm
just trying to find the one that involves the least custom code.

Clearly trying to get an Appointment with Client and Counselor details
is not a one-step process, at least I can't see it.

Brian


Olivier Percebois-Garve wrote:
> what if look at Appointment being the relation table between Client and
> Counselor in a HABTM relation?
>
> [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