magento直接操作数据库
时间:2021-07-01 10:21:17
帮助过:2人阅读
增
$write = Mage::getSingleton("core/resource")->getConnection(‘core_write‘);
$table = Mage::getSingleton(‘core/resource‘)->getTableName(‘abc‘);
$write->insert($table,array(‘name‘=>‘hello‘));
改
$write = Mage::getSingleton("core/resource")->getConnection(‘core_write‘);
$table = Mage::getSingleton(‘core/resource‘)->getTableName(‘abc‘);
$write->update($table,array(‘name‘=>‘abc‘),array(‘id‘=>3));
删
$write = Mage::getSingleton("core/resource")->getConnection(‘core_write‘);
$table = Mage::getSingleton(‘core/resource‘)->getTableName(‘abc‘);
$write->delete($table,array(‘id‘=>3));
查
$read = Mage::getSingleton("core/resource")->getConnection(‘core_read‘);
$table = Mage::getSingleton(‘core/resource‘)->getTableName(‘abc‘);
$result = $read->select()->from(array(‘main_table‘=>$table))->where(‘main_table.id‘,3)->limit(1);
$products=$read->fetchAll($result);
magento直接操作数据库
标签: