Just to clarify, what i'd done (with both just pointing to Article)
didn't work and borked out with an error "non-unique key Article" or
something similar...

Seb

On Jan 7, 1:28 pm, Seb <[EMAIL PROTECTED]> wrote:
> This is interesting - I'd previously tried without using the HABTM
> part:
>
> class Article extends AppModel {
>   var $name="Article";
>   var $hasMany=array("Article");
>   var $belongsTo=array("Article");
>
> }
>
> and let Cake deal with the automatic matching of Article names to ids
> etc - you've created differently named elements, then mapped them
> specifically to Article - i've just tried this and it seems to work!
>
> Thanks for the help - if you can offer any more explanation of why/how
> this works, that would be great :D
>
> Thanks
>
> Seb
>
> On Jan 7, 1:22 pm, grigri <[EMAIL PROTECTED]> wrote:
>
> > If your structure is really tree-like, then a HABTM relationship is
> > not really useful.
> > The main question to an answer is "can one article have several
> > parents?". As in direct parents, not hierarchy. If it can, then your
> > structure is not a tree, and HABTM should be used, and you'll have to
> > create a join table.
>
> > If, as your database structure suggests, each article has one (or
> > zero) parents, then the structure is tree-like and HABTM is not
> > necessary. Each article "hasOne" parent article and "hasMany" child
> > articles:
>
> > class Article extends AppModel {
> >   var $name = "Article";
>
> >   var $belongsTo = array('Parent' => array('className' => 'Article',
> > 'foreignKey' => 'article_id'));
> >   var $hasMany = array('Child' => array('className' => 'Article',
> > 'foreignKey' => 'article_id'));
>
> > }
>
> > Depending on the complexity of your structure, it might be worth
> > looking at the tree behavior. However, if your nestings aren't very
> > deep then this approach should work fine.
>
> > On Jan 7, 12:50 pm, Seb <[EMAIL PROTECTED]> wrote:
>
> > > Hello!
>
> > > I'm only just starting on the cakephp business, and so far, i'm
> > > impressed - i've run through most of the tutorials i could find on the
> > > web relating to cake, and the IBM ones too so got a fairly good
> > > understanding of what's going on...
>
> > > I've hit a wall though - in the thing I'm writing at the mo, there is
> > > a tree structure (of sorts) with:
>
> > > Issue -> Section -> Article
>
> > > So, an issue hasMany("Section"). Fine.
> > > Section hasMany("Article"). Still fine.
> > > Article hasAndBelongsToMany("Article")
>
> > > It's the last one that's causing problems - my article table structure
> > > is something along the lines of:
>
> > > article(id, article_id, title, body, created, modified)
>
> > > so i don't have a join table to join the articles on to themselves,
> > > the article just stores if it has a parent article or not.
>
> > > I can't get this to work with the scaffolding part I'm working on at
> > > the moment as it keeps trying to look for a articles_articles table
> > > (which i don't think (correct me if i'm wrong) i want nor need)
>
> > > Any help would be greatly appreciated!
>
> > > Thanks
>
> > > Seb Maynard
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to