异常回滚的php系统设计
我有一个系统,可以根据要求执行以下操作 提取 zip、创建目录、插入数据库信息
它可能在任何阶段因任何原因而失败,可能是权限、文件格式错误、数据库错误。 我不希望系统由于任何异常而部分执行。
我究竟如何实施回滚系统? 我的想法是,对于每个操作,将其推入堆栈或数据库,执行相反操作的字符串函数,对于任何失败,将其弹出并对其进行评估。
在开始之前,还有其他内置方式或任何提示吗?
I have a system which upon request does things such as
extracts zip, creates directories, inserts database information
It could fail for whatever reason at any stage, maybe permissions, bad file format, database error.
I don't want the system to have partial executions due to any exceptions.
How exactly would I implement a rollback system ?
What I'm thinking is for every action push into a stack or database a string function execution of the opposite action and for any failure pop it and do an eval on it.
Any other built in way or any tips before I start this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我运行这种情况,我能想到的最好的方法是在过程中进行验证(提取邮政编码,测试数据库连接,验证用户名可用,等等),在过程结束时我应用所有 nessery 函数(提交数据、注册用户...)。
I run this some situation, best I could to figure is to make verfications during the process(extract zip code, test database connection, verfier the user name avaialble, and so on), in the end of process I apply all the nessery functions(submit data, register user ...).