On Tue, Aug 25, 2009 at 6:43 AM, gedm<[email protected]> wrote:
>
> Brian,
>
> Sorry if I wasn't clear.  The problem is the ChildComment User_ID
> doesn't associate with the User Model so I can't get the username
> information for the ChildComments.  I jst don't know how to assicate
> the ChildComment model with the User model.  I'm sure it's very easy I
> just can't get my head around associating with the ChildComment Class
> when it's not actually a table.  I know.... newbie.
>

I see now. Try doing this for the User model:

var $hasMany = array(
           'Comment' => array(
                           'className' => 'Comment',
                           'foreignKey' => 'user_id',
                           'dependent' => true
           ),
           'ParentComment' => array(
                           'className' => 'Comment',
                           'foreignKey' => 'user_id',
                           'dependent' => true
           ),
           'ChildComment' => array(
                           'className' => 'Comment',
                           'foreignKey' => 'user_id',
                           'dependent' => true
           )
);

I think that might work. Note that I set dependent = true here. This
will remove all Comments that belong to a User if the latter is
deleted. You'd likely want to do the same for, say, an Article model,
or whatever it is that these Comments belong to besides User.

--~--~---------~--~----~------------~-------~--~----~
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