码迷,mamicode.com
首页 > 数据库 > 详细

magento直接操作数据库

时间:2016-09-08 12:44:43      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

 
     $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直接操作数据库

标签:

原文地址:http://www.cnblogs.com/dongtong/p/5852440.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!