douxidao3524 2012-10-09 06:44
浏览 45
已采纳

MySQL START事务和COMMIT分开发生

This is the scenario: I have multiple users using a PHP page/form to edit data concurrently. The table has rows of data and each user is allowed to edit any one row at a time. The system selects the row to be edited; so, the user is simply given a row to edit; he does not decide which row he will edit.

The first time a user visits the page with form, it load a row. Also, so that the system can decide which row to provide to any other concurrent user, it sets a flag in the database table indicating that the row has been loaded for edit (to another concurrent user).

Now, if the user refreshes the page or quits the page without clicking the Submit button, I want to roll-back the flag change so that the row that was loaded can be made available again for edit.

For this, I am planning to use MySQL transaction. - At the start of the transaction the flag will be set. - Then, the data to be edited will be loaded into the form.

Once, the user edits the data and submits it (by clicking a button), only then Commit will be issued.

So, my understanding is that the START transaction and the Commit will be occurring separately.

Can someone please provide some guidelines on how this can be achieved?

  • 写回答

1条回答 默认 最新

  • doupian9798 2012-10-21 03:48
    关注

    Guess this isn't possible; I am using PHP Session variables instead to accomplish my objective.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog