You just need to change the alias :
class Tag extends AppModel {
var $hasAndBelongsToMany = array(
'RelatedTag' => array('className' => 'Tag')
);
}
In your resultset the `Tag` key will now refer to the "main" tag and
the `RelatedTag` will contain the related tags. Of course you can
change the alias to anything suitable.
On Apr 4, 11:17 am, dizz <[EMAIL PROTECTED]> wrote:
> I was just having the same problem, used your method and it's working
> fine now.
>
> On Mar 30, 9:36 pm, "ste.ve" <[EMAIL PROTECTED]> wrote:
>
> > To visualize it better, these are my example Model definitions
>
> > WORKS:
>
> > class Tag extends AppModel {
>
> > var $hasAndBelongsToMany = array(
> > 'Tag2' => array(
> > 'foreignKey' =>
> > 'tag_id',
>
> > 'associationForeignKey' => 'tag2_id', )
> > );
>
> > }
>
> > class Tag2 extends AppModel {
>
> > var $useTable = "tags";
>
> > var $hasAndBelongsToMany = array(
> > 'Tag' => array(
> > 'foreignKey' => 'tag2_id',
> > 'associationForeignKey' =>
> > 'tag_id',
> > ));
>
> > }
>
> > DOESN'T WORK (in the result set, all rows for Tag2 contain the value
> > from Tag - the number of results is correct, anyhow)
>
> > class Tag extends AppModel {
>
> > var $hasAndBelongsToMany = array('Tag2' );
>
> > }
>
> > class Tag2 extends AppModel {
>
> > var $useTable = "tags";
>
> > var $hasAndBelongsToMany = array( 'Tag' );
>
> > }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---