久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento 捕獲異常并回滾數據庫事務

Magento catching exceptions and rolling back database transactions(Magento 捕獲異常并回滾數據庫事務)
本文介紹了Magento 捕獲異常并回滾數據庫事務的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在研究 Magento 模塊,需要知道是否可以回滾一系列模型保存.基本上,我有五個模型加上我模塊中的幾個模型,我需要一個接一個地保存:

I'm working on a Magento module and need to know if it's possible to roll back a series of model saves. Basically, I have five models plus several from my module that I need to save one after the other:

admin/role
admin/user
core/website
core/store_group
core/store
mymodule/model1
mymodule/model2

我的問題是,每當這些模型中的任何一個拋出異常時,我都需要進入 MySQL 并手動刪除所有已保存的行.這是非常沒有成效的.

My problem is that whenever any of these models throw an exception, I need to go into MySQL and manually delete all the rows that were saved. This is very unproductive.

我很確定 Magento 沒有我可以在我的上下文中訪問的回滾過程.比如我查看了Mage_Core_Model_Abstract,在save方法中,回滾機制都是受保護的.

I'm pretty sure that Magento doesn't have a rollback procedure that I can access in my context. For example, I looked in Mage_Core_Model_Abstract and in the save method, the rollback mechanisms are all protected.

那么,我的問題是,在 Magento 中進行數據庫事務是否有一些我應該注意的最佳實踐?

So, my question is, is there some best practice for doing database transactions in Magento that I should be aware of?

推薦答案

我在核心代碼中看到了以下內容,看起來正是您訂購的.

I've seen the following used in core code, and it looks like its just what you ordered.

$transactionSave = Mage::getModel('core/resource_transaction');
$transactionSave->addObject($model_one)
$transactionSave->addObject($model_two)
$transactionSave->save();

core/resource_transaction 對象允許您添加 Magento 對象,并對它們執行批量保存.試一試,我很想在評論中聽到這對你有用或沒用.

The core/resource_transaction object allows you to add Magento objects, and perform a mass save on them. Give that a try, and I'd love to hear how this does, or doesn't, work for you in the comments.

這篇關于Magento 捕獲異常并回滾數據庫事務的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 成人毛片在线视频 | 91视频18 | 自拍第一页 | 精品久久久久久亚洲综合网 | 午夜免费观看体验区 | 国产一级视频在线 | 成人黄色网址大全 | 俺去俺来也www色官网cms | 99亚洲精品 | 一区二区三区四区在线视频 | 欧美日韩久久久 | 久久精品成人一区 | 本地毛片 | 真人女人一级毛片免费播放 | 国产激情在线观看 | 免费看黄视频网站 | 亚洲国产成人精品久久 | 精品久久久久久久 | 麻豆av一区二区三区久久 | www精品美女久久久tv | 亚洲一区二区三区视频 | 欧美爱爱视频网站 | 国产精品久久国产愉拍 | 国产综合精品一区二区三区 | 中文字幕一区二区三区乱码在线 | 一级毛片在线播放 | 欧美日韩一卡二卡 | 免费在线h视频 | 高清视频一区二区三区 | 国产精品视频免费观看 | 高清一区二区 | 欧美午夜在线 | 91在线一区| www.狠狠操 | 成在线人视频免费视频 | 国产美女黄色片 | 亚洲精品白浆高清久久久久久 | 欧美精品在欧美一区二区少妇 | 久久夜夜| 成人免费观看男女羞羞视频 | 国产在线a |