简体   繁体   English

刷新页面后回滚数据库更新 (PHP)

[英]Rollback Database Update After Refreshing a Page (PHP)

I have a php application where the user can make some changes to an oracle database with adodb .我有一个 php 应用程序,用户可以在其中使用adodb对 oracle 数据库进行一些更改。

After the request is executed, the page is refreshed and the user can see the result.执行请求后,页面刷新,用户可以看到结果。

How would I add an undo option of this UPDATE after refreshing the page?刷新页面后,如何添加此 UPDATE 的撤消选项?

I've tried beginTrans() , but it seems like it automatically rollbacks after the php script is executed.我试过beginTrans() ,但它似乎在执行 php 脚本后自动回滚。

Database transactions are tied to a single connection.数据库事务绑定到单个连接。 Connections are normally closed when the PHP script finishes and trying to make a connection persist for the same user on multiple requests would be very problematic.当 PHP 脚本完成时,连接通常会关闭,并且尝试为同一用户在多个请求上保持连接会非常有问题。

As much as possible, it's best to treat HTTP requests as stateless.尽可能地,最好将 HTTP 请求视为无状态。 Meaning, changes should be committed to the database at the end of every request and an undo in HTTP should probably not be concerned with rolling back a previous transaction, but also actually committing changes in the database.这意味着,应该在每个请求结束时将更改提交到数据库,并且 HTTP 中的撤消可能不应该关心回滚先前的事务,而是实际提交数据库中的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM