问题
i have a belongsToMany association which deletes joinTable data because i just put new connections inside the entity to be persited.
So i read here about the 2 strategys: append and replace.
Replace is the default one. But i could not find out yet how to set it to append strategy?
回答1:
You can define belongsToMany relation with saveStrategy
keyword which accept either append or replace. So code should be like
$this->belongsToMany('Articles', [
'joinTable' => 'articles_tags',
'saveStrategy' => 'append'
]);
For more check official Doc
来源:https://stackoverflow.com/questions/41428439/how-to-configure-saving-strategy-append-for-belongstomany-association