我有很多关于数组的数据,在这种情况下我必须逐个插入SQL ...你能帮我解决这个问题吗?我希望它对插入数据进行排序...我使用手动插入...你能给我解决foreach或循环SQL吗?
$user_id = getUserId();
$current_dttm = getSQLDate();
$org_id = $_SESSION["ehr_org_id"];
$id = $this->getInosId();
list($patient_id,$inf_id,$num,$tindakan_id,$denum)=$args;
$inf_id = explode('%7C',$inf_id);
$inf_id_1 = $inf_id[0];
$inf_id_2 = $inf_id[1];
$inf_id_3 = $inf_id[2];
$inf_id_4 = $inf_id[3];
$inf_id_5 = $inf_id[4];
$inf_id_6 = $inf_id[5];
$inf_id_7 = $inf_id[5];
$num = explode('%7C',$num);
$num_1 = $num[0];
$num_2 = $num[1];
$num_3 = $num[2];
$num_4 = $num[3];
$num_5 = $num[4];
$num_6 = $num[5];
$num_7 = $num[6];
$tindakan_id = explode('%7C',$tindakan_id);
$tindakan_id_1 = $tindakan_id[0];
$tindakan_id_2 = $tindakan_id[1];
$tindakan_id_3 = $tindakan_id[2];
$tindakan_id_4 = $tindakan_id[3];
$tindakan_id_5 = $tindakan_id[4];
$tindakan_id_6 = $tindakan_id[5];
$tindakan_id_7 = $tindakan_id[6];
$denum = explode('%7C',$denum);
$denum_1 = $denum[0];
$denum_2 = $denum[1];
$denum_3 = $denum[2];
$denum_4 = $denum[3];
$denum_5 = $denum[4];
$denum_6 = $denum[5];
$denum_7 = $denum[6];
$sql_inf_1 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_1','$num_1','$tindakan_id_1','$denum_1','','$current_dttm','$current_dttm','$user_id','normal')";
$sql_1 = $db->query($sql_inf_1);
$sql_inf_2 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_2','$num_2','$tindakan_id_2','$denum_2','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_2);
$sql_inf_3 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_3','$num_3','$tindakan_id_3','$denum_3','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_3);
$sql_inf_4 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_4','$num_4','$tindakan_id_4','$denum_4','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_4);
$sql_inf_5 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_5','$num_5','$tindakan_id_5','$denum_5','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_5);
$sql_inf_6 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_6','$num_6','$tindakan_id_6','$denum_6','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_6);
$sql_inf_7 = "insert into xocp_ehr_pencatatanInos (id,patient_id,org_id,inf_id,num,tindakan,denum,pengali,tgl_kejadian,created_dttm,created_user,status_cd)"
." values('$id','$patient_id','$org_id','$inf_id_7','$num_7','$tindakan_id_7','$denum_7','','$current_dttm','$current_dttm','$user_id','normal')";
$db->query($sql_inf_7);
我想在sort
上插入所有变量1 - 7答案 0 :(得分:1)
您可以在一个Diff
查询中放置多组值。因此,连接您要插入的所有值。
Diff