yagan83
yagan83

Reputation: 65

Cakephp 2 update multiple records

i'm newbie in cakephp and i trying to update multiple rows in one transaction like:

$Model->saveMany($data, array('deep' => true));

... And the structure of the $data array is:

$data = array(
  (int) 1 => array( 'Item' => array('id' => 2, 'name' => 'Name 1') ),
  (int) 2 => array( 'Item' => array('id' => 3, 'name' => 'Name 2') ),
);

I Already tried with saveAll instruction and without deep parameter but nothing :( .... what's wrong?

Thanks for the help :)

Upvotes: 1

Views: 575

Answers (2)

yagan83
yagan83

Reputation: 65

The problem was that it had a required field in the validation that, although it was not compromised in the update, anyway it had to be passed in command

Thank you all!!

Upvotes: 1

K.Suthagar
K.Suthagar

Reputation: 2306

You can use this following code to insert data in Cake Php,

$this->request->data = Hash::insert($this->request->data);

Upvotes: 0

Related Questions