I have so many fields in my custom table. When, I update records at that time, I save records as like below code :


But, I don't want to use setData() multiple times. Then, how to save records just using one time setData().

Anyone know about this?


You need to add your primary key field also in array and add that field value in array. Then, add array in setData() like this way :

$array['id'] = $id; //add your primary key field of the table
$array['field_1'] = $field_1;
$array['field_2'] = $field_2;
$array['field_3'] = $field_3;
$array['field_4'] = $field_4;
$array['field_5'] = $field_5;
$array['field_6'] = $field_6;

Hope, It will useful for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy