0

i have a table(user table) which is associated to many tables. While saving data, it is getting saved in all associated table. But in some scenario i need to save only in base table (User) not in assoicatied table.

In cakephp 2 we have option callback => false, but how can we achive this in cake php 3?

2 Answers2

0

You may specify the associated tables in which you want to save (cf: CakePHP ORM Documentation).

You could then do :

$this->Users->save($user, ['associated' => false]);

To disable the save in associated tables. (I have not tested as I'm at work, I will edit my message if it does not work for me !)

MRousse
  • 526
  • 1
  • 4
  • 9
0

following code worked for me

$entity = $this->Users->newEntity($this->request->data, ['ignoreCallbacks' => true,'associated' => []]);

$result = $this->Users->save($entity);