开发者

Need Help Understanding Doctrine 2's ArrayCollection::clear()

开发者 https://www.devze.com 2023-02-01 18:28 出处:网络
I just don开发者_如何学运维\'t really get this part Say you clear a collection of tags by calling $post->getTags()->clear(); and

I just don开发者_如何学运维't really get this part

Say you clear a collection of tags by calling $post->getTags()->clear(); and then call $post->getTags()->add($tag). This will not recognize tag being already added before and issue two database calls.

What 2 database calls will be issued? Delete all tags of the post then add one? Thats what I'd expect? Or will it be something else?


Did you try to call after the clear?

$entityManager->flush();  

If this don't help try to remove one by one in foreach.

0

精彩评论

暂无评论...
验证码 换一张
取 消