异常回滚的php系统设计

发布于 2024-11-08 22:33:48 字数 218 浏览 3 评论 0原文

我有一个系统,可以根据要求执行以下操作 提取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞取 2024-11-15 22:33:48

我运行这种情况,我能想到的最好的方法是在过程中进行验证(提取邮政编码,测试数据库连接,验证用户名可用,等等),在过程结束时我应用所有 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 ...).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文