Deleting a HABTM Association Record

I have two models, messages and tags. Posts by HasAndBelongsToMany Tags.

Suppose Post 1 has tags for peace, news, and paper.

Now in the connection table I want to remove the link between the paper tag and Mail 1, but the paper tag should not be removed from the tag table. Only the association in the connection table should be deleted.

How to do it in CakePHP?

+3
source share
1 answer

When you perform a HABTM operation other than adding a new one, Cake deletes and re-creates the related rows in the connection table. All you have to do is get the entry, remove the tag and save the entry again.

. , ( - ), .

: http://mrphp.com.au/code/working-habtm-form-data-cakephp

+4

Source: https://habr.com/ru/post/1771103/


All Articles