Thanks for the discussion. I understand the HABTM situation, using a
join table. But in my original setup, there is this WordSet and a
Words table. No join, repeating words are just repeated. So this is a
WordSet hasmany Word
WordSet: id, name etc.
Word: id, word_set_id, word etc.
setup.
In the usual blog example, this would be an article with a comment
article hasMany comment
comment belongsTo article.
I created this page for my Wordsets where all words are joined in a
big textarea. When the user submits the form, I check which words are
gone, which are still there and which are new. So I recreate the $this-
>data->['Word'] array.
Then I do a $this->WordSet->saveAll($this->data). Why would the Word
records with word_set_id = (the one that is saved), that are not in
$this->data be kept in the database.
I understand this is a special case. It is far more usual to have
HABTM-associations added to a 'main' form. One usualy uses subforms,
ajax etc for hasMany associations. But not in my case, in which speed
of input is important, as well as atomic saves.
Back to the blog example, this would be a setup where one could add
and remove comments on the page containing the (editable) article as
well. It is not uncommon using dhtml or prototype to add or remove a
textarea to change the comment collection. On submit, one would check
which of the original comments are gone, and change the $data
accordingly, then call saveAll on the article.
I fixed it now figuring out myself which records should go, and this
within a transaction. But because of the relational structure I really
think when the user says saveAll (i.e. save my record and all the
associations), the result should be relationally correct.
b.t.w I think I am using the cake model as it is intended: this is a
hasMany case. Sorry for the confusion started by me adding 'tags' to
the example. Tags carry the habtm tag..
Jelmer
On 27 jan, 16:13, Esoteric <erik.kristen...@gmail.com> wrote:
> Negative, once again you are not using cake model as it is intended,
> if you really truely want to have this behavior ... you need to have
> the following setup ...
>
--~--~---------~--~----~------------~-------~--~----~
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