I need to execute following query in magento
我需要在magento中执行以下查询
DELETE FROM `table_name` WHERE `column1` = '" . $value1. "' and `column2`='" . $value2. "'"
How can I frame this in magento basis like,
我怎样才能在magento基础上构建它,比如
Mage::getModel('module/model')->setId($id)->delete();
Thanks in advance....
提前致谢....
1 个解决方案
#1
1
I am not test it but hope it will work for you
我不是测试它,但希望它对你有用
$collection = Mage::getModel('model/model')->getCollection()
->addFieldToFilter('column1',array('eq'=> $value1))
->addFieldToFilter('column2',array('eq' => $value2))
;
foreach($collection as $coll)
{
Mage::getModel('module/model')->load($coll->getId())->delete();
}
#1
1
I am not test it but hope it will work for you
我不是测试它,但希望它对你有用
$collection = Mage::getModel('model/model')->getCollection()
->addFieldToFilter('column1',array('eq'=> $value1))
->addFieldToFilter('column2',array('eq' => $value2))
;
foreach($collection as $coll)
{
Mage::getModel('module/model')->load($coll->getId())->delete();
}