magento直接操作数据库
Posted 你的左耳耳钉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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直接操作数据库的主要内容,如果未能解决你的问题,请参考以下文章
php 在将现有数据库连接到新的Magento安装时,“处理您的请求时出错!”...请按照以下链接进行操作