sus*_*hay 8 transactions magento
IN Magento如何在单个事务中的多个表中插入数据,如果进程中有任何错误,则回滚.我可以编写自定义查询并使用事务,但我更愿意,如果我可以使用Magento方法.
Rob*_*ton 29
如果您尝试做的是模型保存,则接受的答案很好.这将允许您将任何数字与回滚链接在一起.
但是,如果您正在执行可能触发回滚或自行回滚的其他操作,那么您希望使用更低级别的内容:
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
try {
$connection->beginTransaction();
// Make saves and other actions that affect the database
$connection->commit();
} catch (Exception $e) {
$connection->rollback();
}
Run Code Online (Sandbox Code Playgroud)
您也可以从模型中获取连接,但可能没有可用的连接.
| 归档时间: |
|
| 查看次数: |
13086 次 |
| 最近记录: |