mysql不会同时插入5到10个用户提交的相同php表单的所有数据

mysql不会同时插入5到10个用户提交的相同php表单的所有数据,php,mysql,bulkinsert,Php,Mysql,Bulkinsert,我使用php表单提交学费。如果单个用户提交该表单,则一切正常,数据保存在MySQL数据库中。但如果我使用同时从5-10个不同的系统提交该表单,则MySQL仅插入两个或三个用户的数据。 我正在使用发票id的触发器: CREATE TRIGGER `test_trig` BEFORE INSERT ON `student_fee_transaction_details` FOR EACH ROW BEGIN SET NEW.inv_no=(SELECT CONCAT(NEW.school_

我使用php表单提交学费。如果单个用户提交该表单,则一切正常,数据保存在MySQL数据库中。但如果我使用同时从5-10个不同的系统提交该表单,则MySQL仅插入两个或三个用户的数据。 我正在使用发票id的触发器:

CREATE TRIGGER `test_trig` BEFORE INSERT ON `student_fee_transaction_details`
 FOR EACH ROW BEGIN
    SET NEW.inv_no=(SELECT CONCAT(NEW.school_id,'-', SUBSTRING_INDEX( inv_no,  '-', -1 ) +1 ) AS inv_number_new
FROM student_fee_transaction_details
WHERE id IN (SELECT MAX( id ) FROM student_fee_transaction_details WHERE school_id = NEW.school_id
));
END
下面是我要插入的php代码
只需将您的id列设置为自动递增,并且在查询中不要将
id
值设置为
'
。 像这样

insert into student_fee_transaction_details (fine_amount,interest_amount,handling_charges,
institute_id,school_id,student_id,class_id,section_id,admission_no,fees_amount,payment_date,
payment_mode,paid_amount,inv_date,inv_ref_no,inv_no,inv_status,session,payment_bank,payment_type,
cheque_dd_no,payment_chanel,fee_due_date,cheque_dd_date,remarks,deposit_bank_id)
values('$fine_amt','$interest_amt','$hand_charge','$ins_id','$sch_id','$stu_id','$cls_id',
'$sec_id','$adm_no','$total_fee_paid_amt','$pay_dt','Manual','$total_paid_amt','$inv_dt',
'$ref_no','1898776','Invoiced','$session','$bank_nm','$pay_type','$dd_chq_no','web',
'$fee_due_date','$dd_cheq_dt','$swipe_remarks','$deposit_bank')";
 $result_inv_master = $con->query($qry_inv_master); 

进行更改后,此问题将不会再次出现。

只需将id列设置为自动递增,并且在查询中不要将
id
值设置为
'
。 像这样

insert into student_fee_transaction_details (fine_amount,interest_amount,handling_charges,
institute_id,school_id,student_id,class_id,section_id,admission_no,fees_amount,payment_date,
payment_mode,paid_amount,inv_date,inv_ref_no,inv_no,inv_status,session,payment_bank,payment_type,
cheque_dd_no,payment_chanel,fee_due_date,cheque_dd_date,remarks,deposit_bank_id)
values('$fine_amt','$interest_amt','$hand_charge','$ins_id','$sch_id','$stu_id','$cls_id',
'$sec_id','$adm_no','$total_fee_paid_amt','$pay_dt','Manual','$total_paid_amt','$inv_dt',
'$ref_no','1898776','Invoiced','$session','$bank_nm','$pay_type','$dd_chq_no','web',
'$fee_due_date','$dd_cheq_dt','$swipe_remarks','$deposit_bank')";
 $result_inv_master = $con->query($qry_inv_master); 

进行更改后,此问题将不会再次出现。

您实际上是在为下一个库存编号选择“max+1”,这意味着您已经设计了一个单用户系统。使用autoincrement或sequences或MySQL提供的任何东西使并发使用成为可能。您实际上是在为下一个inv_no选择“max+1”,这意味着您已经设计了一个单用户系统。使用autoincrement或sequences或MySQL提供的任何东西使并发使用成为可能。