> 1. A litle background about what are you trying to do.

I have Person information that is common to all people (name,
nationality, birthdate). But People can be different things though,
like Coaches, Players, Officials etc. These Person Types can have
statistical information like player stats for players or win/loss
records for coaches. I didn't want to lump unnecessary information
onto Person that didn't need it , so I broke each of these types out
to sep. tables and models

> 2. The code you are using to define the models.

class Person extends AppModel {

        var $name = 'Person';
        var $actsAs = array('Polymorphic');

        // The database table for this model includes 'class' and
'foreign_id' fields
        // No associations to person types exist here
}

class CoachRating extends AppModel {

        var $name = 'CoachRating';

        var $hasMany = array(
                'Person' => array(
                        'className' => 'Person',
                        'foreignKey' => 'foreign_id',
                        'conditions' => array('Person.class' => 'CoachRating'),
                        'dependent' => true
                )
        );
}

> 3. How are you calling the models.

When I go to view one Person in particular, I use

$this->set('person', $this->Person->read(null, $id));

> 4. The SQL that is beign generated.

SELECT `Person`.`id`, `Person`.`birthdate`, `Person`.`firstname`,
`Person`.`lastname`, `Person`.`country_id`, `Person`.`person_type_id`,
`Person`.`class`, `Person`.`foreign_id` FROM `persons` AS `Person`
WHERE `Person`.`id` = 4045 LIMIT 1
SELECT `CoachRating`.`id` FROM `coach_ratings` AS `CoachRating` WHERE
`CoachRating`.`id` = 8 LIMIT 1

> 5. The version of cake you are using.

1.2.0.6311 beta

Thanks! rob

On Apr 1, 11:24 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> Missing information:
>
> 1. A litle background about what are you trying to do.
> 2. The code you are using to define the models.
> 3. How are you calling the models.
> 4. The SQL that is beign generated.
> 5. The version of cake you are using.
>
> On Tue, Apr 1, 2008 at 12:11 PM, rob5408 <[EMAIL PROTECTED]> wrote:
>
> >  I followed the Bakery page on setting up my db and models for the
> >  Polymorphic Behavior and it looks like I'm almost there, but the rest
> >  of the db fields for my associated model aren't being included. I'm
> >  seeing a return like this...
>
> >  Array
> >  (
> >     [Person] => Array
> >         (
> >             [id] => 4045
> >             [birthdate] => 1978-04-11
> >             [firstname] => Donald
> >             [lastname] => Marks
> >             [class] => CoachRating
> >             [foreign_id] => 8
> >         )
>
> >     [CoachRating] => Array
> >         (
> >             [id] => 8
> >             [display_field] => 8
> >         )
>
> >  )
>
> >  but 'display_field' isn't a field in CoachRating table and there's two
> >  fields omitted. Maybe I'm trying to use this behavior when another
> >  would be more logical. Thanks, rob
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to