我的网络应用正在运行。它将单元格从excel文件导入到MS SQL Server数据库。我想知道是否有可能在插入数据库之前检查重复的条目?
if(!empty($data) && $data->count()){
foreach ($data as $key => $value) {
$insert[] = [
'type' => $value->type,
'f_name'=> $value->f_name,
's_name' => $value->s_name,
'gender' => $value->gender,
'email' => $value->email,
'address'=>$value->address,
'field_of_study' => $value->field_of_study,
'user_id' => $value->user_id,
'mobile' => $value->mobile,
'sector' => $value->sector,
'b_date' => $value->b_date,
'orgnaization' => $value->orgnaization,
'job_title' => $value->job_title,
'note' => $value->note
];
}
if(!empty($insert)){
foreach($insert as $i => $item) {
if(($insert[$i]['f_name']!= null)){
$insertData =DB::insert('insert into person (
f_name, s_name, address, field_of_study,
gender, type, job_title, orgnaization, mobile, sector, email, user_id, note
) values (?, ? , ? , ?, ? ,?, ?, ? ,? ,? ,? ,? ,? )', [
$insert[$i]['f_name'],
$insert[$i]['s_name'],
$insert[$i]['address'],
$insert[$i]['field_of_study'],
$insert[$i]['gender'],
$insert[$i]['type'],
$insert[$i]['job_title'],
$insert[$i]['orgnaization'],
$insert[$i]['mobile'],
$insert[$i]['sector'],
$insert[$i]['email'],
$insert[$i]['user_id'],
$insert[$i]['note'],
]);
}