Hi @van1310 If you have specific $editrow for every specific $id - you can't update multiple rows at once. Only if you have the same $editrow for a bunch of ids
Oct 15, 2020
11
Level 13
how to array to update multiple rows
hii i m stuck in array through update my records i have array set in which i update multiple rows so how can i do it here is my code
if(!empty($requestData['edit_email']) && count($requestData['edit_email']) > 0){
foreach($requestData['edit_email'] as $i => $list){
$ids = array();
$editdata = array();
array_push($ids,$requestData['fid']);
$editrow['email']=$requestData['edit_email'][$i];
$editrow['phone'] = NULL;
// dd($requestData['edit_email_alert_level']);
switch($requestData['edit_email_alert_level'][$i]){
case "0":
$editrow['alert_level'] = "client";
$editrow['client_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;
$editrow['salescenter_id'] = NULL;
$editrow['location_id'] = NULL;
break;
case "1":
$editrow['alert_level'] = "salescenter";
$editrow['salescenter_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;
$editrow['client_id'] = NULL;
$editrow['location_id'] = NULL;
break;
case "2":
$editrow['alert_level'] = "sclocation";
$editrow['location_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;
$editrow['salescenter_id'] = NULL;
$editrow['client_id'] = NULL;
break;
default:
break;
}
}
array_push($editdata,$editrow);
FraudAlert::where('id', $ids)->update($editdata);
// dd($ids);
// dd($requestData['fid']);
}
when i update record then error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update fraud_alerts set 0 = [email protected], updated_at = 2020-10-15 05:23:31 where id = 222)
Please or to participate in this conversation.