zoukankan      html  css  js  c++  java
  • magento直接操作数据库

    查:

        $read = Mage::getSingleton("core/resource")->getConnection('core_read');
        $sql = "select * from `abc`";    
        $result = $read->fetchAll($sql);  //fetchRow查找一条
     
    增,删,改
        $write = Mage::getSingleton("core/resource")->getConnection('core_write');
         $sql = "insert into abc (name)values('hello')";
         $write->query($sql);
     
    另一种写法:
         $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);
    唯一不同的只是一个sql语句是组装的,一个是直接写的
  • 相关阅读:
    K8s PV and PVC and StorageClass
    WebSphere--WAS概念和原理解析
    K8S配置多集群访问
    ROS2学习日志:CV开发之关联Gazebo/Webots/ROS2
    CV学习日志:Orbslam使用总结
    CV学习日志:Basalt使用总结
    CV学习日志:Kalibr使用总结
    CV学习日志:CamOdoCalib使用总结
    CV学习日志:OpenVINS使用总结
    CV学习日志:搭建U2004开发环境
  • 原文地址:https://www.cnblogs.com/aqxinzhuan/p/3047094.html
Copyright © 2011-2022 走看看