我要把头发拉出来...为什么不跑呢?
Mage::getSingleton('core/resource')->getConnection('core_write')->query('DELETE FROM catalog_product_super_attribute WHERE product_id = 46');
当我通过命令行运行该查询时,或者甚至是phpmyadmin,当我尝试使用它不起作用的代码运行它时,它执行就好了删除所有行。我甚至尝试绕过Magento,希望它与他们有关但是当我尝试在php中使用直接mysql或mysqli删除时它也无法正常工作。
任何想法或建议都很棒。
答案 0 :(得分:1)
$transaction = Mage::getSingleton('core/resource')->getConnection('core_write');
try {
$transaction->beginTransaction();
$transaction->query('DELETE FROM catalog_product_super_attribute WHERE product_id = 46');
$transaction->commit();
} catch (Exception $e) {
$transaction->rollBack(); // if anything goes wrong, this will undo all changes you made to your database
}