I would use the Containable behavior, and use that to specify which
model to return.

eg:
$contain = array(
                        'School',
                         'Competitor' => array(
                            'Trackmeet',
                            'Student' => array(
                                  'School'
                             )

                         )
                   );
$trackmeets = $this->Trackmeet->find('all',compact('contain'));

or something along those lines.
that being said, it seems to me that students are competitors. I would
probably do a Student hasAndBelongsToMany Trackmeet and get rid of the
Competitor model.

-d

On May 27, 8:14 am, "jason.t.stein" <[email protected]> wrote:
> In the project I am working on, I have the following models:
>
> class Student extends AppModel
> {
>   var $name = 'Student';
>   var $belongsTo = 'School';
>   var $hasMany = 'Competitor';
>
> }
>
> class Competitor extends AppModel
> {
>   var $name = 'Competitor';
>   var $belongsTo = array('Student','Trackmeet');
>
> }
>
> class School extends AppModel
> {
>   var $name = 'School';
>   var $hasMany = array('User','Student','Trackmeet');
>
> }
>
> class Trackmeet extends AppModel
> {
>   var $name = 'Trackmeet';
>   var $belongsTo = 'School';
>   var $hasMany = 'Competitor';
>
> }
>
> class Trackmeet extends AppModel
> {
>   var $name = 'Trackmeet';
>   var $belongsTo = 'School';
>   var $hasMany = 'Competitor';
>
> }
>
> In the Trackmeet controller, I am able to select all of the
> competitors in a specific event which returns an array with elements
> ('Competitor','Student','Trackmeet). I would like to be able to find
> out the name of the school the student attends so I can pass it to the
> appropriate view.  Do I have to do a separate query based on school_id
> in the student model or is there an easier way?
>
> Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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