That did it, thanks for all your help! Rob

On Apr 1, 4:55 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> There is a bug in the behavior that make it fetch only id and
> displayfield (that is a virtual field and is documented in the
> behavior. ).
>
> In the line 45, change:
>
>                                                 array('id', 
> $model->$class->displayField), null, -1);
> to:
>
>                                                 null, null, -1);
>
> Link to fixed version:
>
> http://bin.cakephp.org/view/1702492171
>
> This is the patch:
>
> ----------BEGIN-PATCH-------------------
> --- polymorphic_original.php    2008-04-01 17:57:56.000000000 -0300
> +++ polymorphic.php     2008-04-01 17:58:50.000000000 -0300
> @@ -42,7 +42,7 @@
>                                                 )));
>                                         }
>                                         $associated = 
> $model->$class->find(array($class . '.id' => $foreignId),
> -                                               array('id', 
> $model->$class->displayField), null, -1);
> +                                               null, null, -1);
>                                         $associated[$class]['display_field'] =
> $associated[$class][$model->$class->displayField];
>                                         $results[$key][$class] = 
> $associated[$class];
>                                 }
> -----------END-PATCH-------------------
>
> On Tue, Apr 1, 2008 at 12:38 PM, rob5408 <[EMAIL PROTECTED]> wrote:
>
> >  > 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