63509

How to configure saving strategy (append) for belongsToMany Association?

Question:

i have a belongsToMany association which deletes joinTable data because i just put new connections inside the entity to be persited.<br /> So i read <a href="https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-belongstomany-associations" rel="nofollow">here</a> 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?

Answer1:

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 <a href="https://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations" rel="nofollow">Doc</a>

Recommend

  • Currency Format with Knockout
  • Implementation of Atomic Transactions in dynamodb
  • Android: Delete Notification only when touched not throuch “clear all” Button
  • Cleanup partly-uploaded files handled by TemporaryFileUploadHandler in Django
  • how we delete a row from parent table when child table connected with paren table by forigen key
  • test if a form input is a 1 or 2 digit integer with jquery and php
  • Sieve of Eratosthenes - Implementation returning some non-prime values?
  • MySql Triggers to delete child records in the same table
  • Does supervisor block calls while restarting children?
  • How can I get test kitchen run same chef recipe multiple times?
  • MongoDB auto increment ID
  • Delphi 7 - How to delete an item from listview using its caption
  • How to determine differences in two lists of data
  • Delphi XE6 - How to make user defined components image show up on the pallette
  • How to make a user wait with Laravel
  • Geom_jitter colour based on values
  • Replace last two characters in column
  • NSIS decompiler
  • PayPal API Listener Website Payments Standard URI
  • Doctrine/Symfony entity generator and generating entity from one table
  • SAXReader not re-ecape characters
  • Why cepheus don't send int without quotes to orion?
  • GAE: Way to get reference to an HttpSession from its ID?
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • Force show.bind execution
  • wxPython: displaying multiple widgets in same frame
  • Checking free space on FTP server
  • Javascript simulate pressing enter in input box
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • Modifying destination and filename of gulp-svg-sprite
  • GridView Sorting works once only
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • How to delete a row from a dynamic generate table using jquery?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • Is there any way to bind data to data.frame by some index?