You have a name collision for starters.  The class Topic has the name Topic,
and its Associations have the same name.  You can try changing the aliases
like hasMany ChildTopic and belongsTo ParentTopic.  Just make sure to keep
the className as Topic.

Jeff


On Sat, Nov 14, 2009 at 1:22 PM, LancerForHire <[email protected]>wrote:

> How can I self join a model? I want the Topic Model to have many child
> topics or be the child of one topic. I am trying to use:
>
>  <?php
> class Topic extends AppModel {
>        var $name = 'Topic';
>        var $hasMany = array(
>                'Topic' => array(
>                        'className'  => 'Topic',
>                        'foreignKey' => 'parent_id'
>                )
>        );
>        var $belongsTo = array(
>                'Topic' => array(
>                        'className'  => 'Topic',
>                        'foreignKey' => 'parent_id'
>                )
>        );
> }
> ?>
>
> But I get the following error in the index view:
>
> Warning (512): SQL Error: 1066: Not unique table/alias: 'Topic'
>
> Thanks for the 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]<cake-php%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=.
>
>
>

--

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=.


Reply via email to