使用 Datamapper/Codeigniter 提交事务后可以回滚事务吗?
事务提交后是否可以回滚? 我问这个问题是因为在 Datamapper 文档中我看到了 trans_begin()
方法,但我没有找到 trans_end()
方法。 Codeigniter 有 trans_complete()
方法,所以我假设 Datamapper 可能有类似的方法。
我发现有趣的一件事是 这个答案。 Datamapper/Codeigniter 中是否有类似于保存点的东西?
Is it possible to rollback a transaction after it has been commited?
I ask this because in the Datamapper documentation i see the trans_begin()
method, but i didn't find the trans_end()
method. Codeigniter has the trans_complete()
method, so i assumed Datamapper might have a similar method.
One thing I found interesting is this answer. Is there anything similar to a savepoint in Datamapper/Codeigniter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着,
您将使用:
根据 Datamapper 文档,其他所有内容在事务方面与 Codeigniter 相同。如果您查看 Datamapper 库的源代码,您会发现所有
trans_*()
调用都只是包装函数。示例:Codeigniter 或 Datamapper 中都不存在
trans_end()
方法。您可以使用trans_start()
和trans_complete()
进行自动事务,或手动调用它们:只需将
$this->db
替换为您的 Datamapper 对象即可。例如。This means that instead of:
You'd use:
Everything else, according to the Datamapper documentation, is identical to Codeigniter in regards to transactions. If you look at the source code for the Datamapper library, you'll see that all
trans_*()
calls are simply wrapper functions. Example:A
trans_end()
method does not exist in either Codeigniter or Datamapper. You'd usetrans_start()
andtrans_complete()
for automatic transactions, or to call them manually:Just replace
$this->db
with your Datamapper object. For example.