Re: hasAndBelongsToMany help

2007-09-24 Thread [EMAIL PROTECTED]


This is definately a Habtm issue, with an articles_articles table (or
whatever) to join on, and say,

article_id,
related_id

fields.

Now there may be some fancy shmancy way to do what you're talking
about, but since no one's answered, I'll give you a quick and dirty
solution.

With the above model, just modify your controler, so that when an
association is created in one direction, it is simultaneously created
in the reverse direction.  Equally you need to delete the paired
associations at the same time.

But this solves your 'related' problem, or anyone's reflexive
associations.  Like I said, there might be a better way to do it, and
if so I'd like to learn it, but this will get you covered.

Jeff

On Sep 21, 11:51 am, kionae [EMAIL PROTECTED] wrote:
 My issue here is that I have an Article model and I want to be able to
 associate articles with other articles.  It works in as much as I can
 relate one article to several others, but I need the relationship to
 go both ways.

 For example, in the backend of my site, a user associates article 1
 with article 75 and in the view of article 1, article 75 is listed as
 a related article... but is there a way to make it so that the view
 for article 75 lists article 1 under as a related article, as well?

 I've tried searching for information, but I can't seem to hit upon the
 right set of search terms.  Surely someone must have needed to do this
 at some point.

 This is what I currently have in my Article model.

 var $hasAndBelongsToMany = array(
'RelatedArticle' = array('className' =
 'Article',
 'joinTable' =
 'articles_articles',
 'foreignKey' =
 'article_id',

 'associationForeignKey' = 'related_id',
 'conditions' = '',
 'fields' = '',
 'order' = '',
 'limit' = '',
 'offset' = '',
 'unique' = '',
 'finderQuery' = '',
 'deleteQuery' = '',
 'insertQuery' = ''),
);


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



hasAndBelongsToMany help

2007-09-21 Thread kionae

My issue here is that I have an Article model and I want to be able to
associate articles with other articles.  It works in as much as I can
relate one article to several others, but I need the relationship to
go both ways.

For example, in the backend of my site, a user associates article 1
with article 75 and in the view of article 1, article 75 is listed as
a related article... but is there a way to make it so that the view
for article 75 lists article 1 under as a related article, as well?

I've tried searching for information, but I can't seem to hit upon the
right set of search terms.  Surely someone must have needed to do this
at some point.

This is what I currently have in my Article model.

var $hasAndBelongsToMany = array(
   'RelatedArticle' = array('className' =
'Article',
'joinTable' =
'articles_articles',
'foreignKey' =
'article_id',
 
'associationForeignKey' = 'related_id',
'conditions' = '',
'fields' = '',
'order' = '',
'limit' = '',
'offset' = '',
'unique' = '',
'finderQuery' = '',
'deleteQuery' = '',
'insertQuery' = ''),
   );


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---