The event table has eventtype_id as the FK.

The SQL for

$this->Event->find('first');

does a simple select from events with no joins or errors, which is the
confusing part. It is like Cake isn't trying to get the parent
information.

On Sep 24, 7:15 pm, teknoid <[EMAIL PROTECTED]> wrote:
> Are your foreign keys named correctly?
> What does your SQL debug tell you about the query?
>
> On Sep 24, 1:06 pm, James  Pearson <[EMAIL PROTECTED]> wrote:
>
> > Good Evening,
>
> > I'm new to cake, and have reached a dead end with  a hasMany, belongTo
> > problem, and wondered if you guys could help.
>
> > This problem has 2 models, Event and EventType.
>
> > An Event belongs to an Event Type, for example a soccer match event
> > would be of the sports event type.
>
> > My models are setup as follows:
>
> > class Event extends AppModel {
> >         var $name = 'Event';
>
> >         var $belongsTo = 'Eventtype';
>
> > }
>
> > class Eventtype extends AppModel {
>
> >         var $name = 'Eventtype';
>
> >         var $hasMany = 'Event';
>
> > }
>
> > The problem occurs when I retrieve an event in my controller. If I
> > try:
>
> > debug($this->Eventtype->find('first'));
>
> > This spits out the first event type, and all events of that type...
> > which is the expected result. However if I try:
>
> > debug($this->Event->find('first'));
>
> > Then the output is only the details of the first event, and no attempt
> > to join to the eventtypes table is made in any of the queries.
>
> > The documentation (http://book.cakephp.org/view/78/Associations-
> > Linking-Models-Together) would have me  believe that the belongsTo
> > relationship should also retrieve the details of the parent.
>
> > Can anyone help me out?
>
> > Thanks
>
> > James

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to