if you really truely want to have this behavior ... you need to have
the following setup ...
tables
-----------
articles
tags
articles_tags
associations
--------------------
article HABTM tag
tags HABTM article
set the unique variable to true in the association
now when you do a saveAll, any current tags associated with the
article will be deleted first, then the ones you have selected before
the saveAll will be inserted into the articles_tags table, thus
effectively deleting any tags you odn't want anymore ..
-Erik
On Jan 27, 6:22 am, Jelmer <goo...@spininhetweb.nl> wrote:
> > Isn't an alarm bell ringing that you're calling a method called
> > saveAll and wanting it to delete?
>
> Well yes and no. When you are saving say an article, you use saveAll
> to save the article with all its tags, comments and all. These are not
> HABTM, but simple 1:n hasMany relationships. So when a user has
> deleted a tag with the article, saving of the changes actually means
> deleting the tag (that is, the record that says that tag X belongs to
> articly Y).
>
> This is what the normal forms imply. The tag-to-article table in this
> example is fully dependent on the article record. When I save the
> article together with all its tags (saveAll), there should be no tags
> in the database that are not in this save, but still connected to the
> article.
>
> Maybe a better name for the function should be "replaceAll" or
> "saveFull" or something, but it really is what one expects to happen.
> Right?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment