首页 > 代码库 > magento直接操作数据库
magento直接操作数据库
增
$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直接操作数据库
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。