There was abug with saving HABTM data a while back:

http://groups.google.com/group/cake-php/browse_thread/thread/2ad48c4e10f58fc0/c7c4511051071b52#c7c4511051071b52

not sure if it ever got fixed, but you might try out the suggested fix
and see if that helps.

On Apr 29, 5:28 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> Yes, this is something that's come up before, though I can't remember
> the reason (nor the fix).
>
> You might want to check out this TagBehavior, though:
>
> http://bakery.cakephp.org/articles/view/simple-tagging-behavior
>
> On Mon, Apr 28, 2008 at 11:04 PM, AussieFreelancer
>
> <[EMAIL PROTECTED]> wrote:
>
> >  Hi all, I'm sure this must be me, but I can't see what I am doing
> >  wrong so thought I would post here.
>
> >  I am trying to set up a posts/tags kind of thing with a site I am
> >  building which stores presentations. So there can be tags associated
> >  with a presentation.
>
> >  I didn't want a multiple select box for the tags as there could be
> >  hundreds, and that wouldn't allow for adding new ones.
>
> >  So I have a text field, that the user can enter the keywords,
> >  separated with a coma.
>
> >  In my controller, I first remove any entries in the presentations_tags
> >  table, so that it is not associated with any tags.
>
> >  Then I split the value of the field, trim off white space, then loop
> >  through each tag (case insensitive) that has been submitted.
>
> >  If the tag exists, I update the presentations_tags table with the
> >  id's.
>
> >  If the tag does not exist, I first insert it in to the tags table,
> >  then using getLastInsertId() I proceed to update the
> >  presentations_tags table.
>
> >  Everything works, and does what I am asking it to, except that in the
> >  case of a tag not existing, it ALSO adds 4 entries for each tag.
>
> >  These entries always have the id of the tag in the tag_id field, but
> >  they also have the following presentation_id's:
>
> >  0, 2, 3, 10
>
> >  All 4 of these are additional to the desired result, and they always
> >  follow this pattern. If I add two new tags, I have 8 added, 4 for each
> >  tag, and they all follow the above pattern.
>
> >  This is the code I am using for when the tag isnt found:
>
> >  ------------------------------- CODE
> >  -----------------------------------
>
> >  //insert new tag
> >  $this->data['Tag']['name'] = $tag;
> >  $this->Tag->create();
> >  $this->Tag->save($this->data);
>
> >  //get insert id
> >  $last_insert_id = $this->Tag->getLastInsertId();
>
> >  //update presentations_tags
> >  $this->data['PresentationsTag']['presentation_id'] = $id;
> >  $this->data['PresentationsTag']['tag_id'] = $last_insert_id;
>
> >  $this->PresentationsTag->create();
> >  $this->PresentationsTag->save($this->data);
>
> >  ------------------------------------------------------------------------------
>
> >  Has this been experienced before? I cant see any reason for it.
>
> >  As a sidenote, I have created a model for the presentations_tags table
> >  so that I can achieve what I am after.
>
> >  Any help would be greatly appreciated.
>
> >  Many Thanks
>
> >  Patrick
>
>
--~--~---------~--~----~------------~-------~--~----~
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