d, Thanks d. I took a quick read through, and it looks like containables may work. I chose to use the competitor model to avoid duplicating data. I couldn't figure out how to merge competitor and student without always duplicating personal information. I am not a database designer, but this seemed like the easiest way to reduce duplicate data.
On May 27, 9:50 am, d <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
