error save method saving the same value for all rows in cakephp

QuestionsCategory: cake phperror save method saving the same value for all rows in cakephp
VR Soft Coder Staff asked 4 months ago

error save method saving the same value for all rows in cakephp

I am using the below Query:-

 foreach ($customer as $key => $data) {
         	$this->CancelledCustomers->create();
         	$this->CancelledCustomers->save(array('account_number' => $data['Customer']['account_number']));
        }

cakephp save multiple records at once,
cakephp get save error,
cakephp 4 saving data

1 Answers
Best Answer
VR Soft Coder Staff answered 4 months ago

Use clear() instead of create() as below:-

$this->CancelledCustomers->clear();
$this->CancelledCustomers->save(array('account_number' => $data['Customer']['account_number']));

Your Answer

Related Posts

Begin typing your search above and press enter to search. Press ESC to cancel.

Back To Top