Magento数据库交易 [英] Magento Database Transaction

查看:59
本文介绍了Magento数据库交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento中,如何在单个事务中将数据插入多个表中并在过程中出现任何错误时回滚??我可以编写自定义查询并使用事务,但是如果可以使用Magento方法,我会更愿意.

IN Magento How can I insert data in multiple tables in a single transaction and rollback if there is any error in the process.?? I can write custom queries and use transactions but I would prefer if I can do it using Magento methods.

推荐答案

您可以尝试使用Mage :: getModel('core/resource_transaction').诸如此类的文档位于此处.

You can try Mage::getModel('core/resource_transaction'). The documentation for it such as it is here.

但可能更有用,这是一个示例使用它从订单创建发票.

But probably more useful, here is an example of using it to create an invoice from an order.

这篇关于Magento数据库交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆