PHP:如果用户没有按下提交按钮,则Mysql回滚多个查询(通过ajax完成)

时间:2022-06-01 17:55:41

I have one page, within this page insert/update/delete action performed via ajax jQuery.

我有一个页面,在此页面中通过ajax jQuery执行插入/更新/删除操作。

if user don't press submit button or press cancel button than roll-back all changes/query performed via ajax. not possible with temporary table because there are lots of data.

如果用户没有按提交按钮或按取消按钮而不回滚所有通过ajax执行的更改/查询。临时表不可能,因为有很多数据。

Kindly suggest me proper way to do that.

请建议我这样做的正确方法。

2 个解决方案

#1


0  

You can check MySQL Transactions and specifically the ROLLBACK statement if your database is InnoDB. It will do your job.

如果您的数据库是InnoDB,您可以检查MySQL事务,特别是ROLLBACK语句。它会完成你的工作。

If you put the query in a transaction, you can commit it if submit button is pushed or rollback it in an other case.

如果将查询放在事务中,则可以在提交按钮时将其提交,或者在其他情况下将其回滚。

#2


0  

Detecting the Page Leave event. And then delete what you want.

检测页面离开事件。然后删除你想要的东西。

window.onbeforeunload = function (e) {
  var message = "Your confirmation message goes here.",
  e = e || window.event;
  // For IE and Firefox
  if (e) {
    e.returnValue = message;
  }

  // For Safari
  return message;
};

#1


0  

You can check MySQL Transactions and specifically the ROLLBACK statement if your database is InnoDB. It will do your job.

如果您的数据库是InnoDB,您可以检查MySQL事务,特别是ROLLBACK语句。它会完成你的工作。

If you put the query in a transaction, you can commit it if submit button is pushed or rollback it in an other case.

如果将查询放在事务中,则可以在提交按钮时将其提交,或者在其他情况下将其回滚。

#2


0  

Detecting the Page Leave event. And then delete what you want.

检测页面离开事件。然后删除你想要的东西。

window.onbeforeunload = function (e) {
  var message = "Your confirmation message goes here.",
  e = e || window.event;
  // For IE and Firefox
  if (e) {
    e.returnValue = message;
  }

  // For Safari
  return message;
};