在Magento中直接使用SQL语句
来源:互联网 发布:java map 红黑树 编辑:程序博客网 时间:2024/05/17 03:53
有时希望在Magento模块中写一些SQL语句,绕过资源模型,可以这样
1.
protected function _getResource(){return Mage::getSingleton('core/resource');}
2.插入操作
$table = $this->_getResource()->getTableName('supplier_serviceprice'); $this->_getResource()->getConnection('core_write')->insert($table, array('product_id' => $productId, "supplier_id" =>$receiverSuppliers[$i],"service_price" => $receiverPrice[$i],"is_primary"=>$primaryReceiver[$i]));
3.删除操作
$table = $this->_getResource()->getTableName('supplier_serviceprice'); $this->_getResource()->getConnection('core_write')->delete($table, $this->_getResource()->getConnection('core_write')->quoteInto('product_id=?', $this->_getProduct()->getId()));
另一种方法
$read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );$results = $read->fetchAll("SELECT supplier_paypal,service_price,is_primary FROM supplier_serviceprice ss INNER JOIN supplier s ON ss.supplier_id = s.supplier_id");echo $results['字段名']}
- 在Magento中直接使用SQL语句
- Magento中直接使用SQL语句
- Magento中直接使用SQL语句
- magento -- 在Magento中使用自己写的SQL语句
- Magento中直接使用SQL语句 select insert update
- magento -- 在Magento中获取SQL语句
- magento 中 直接写sql语句
- 如何在Django中直接使用sql语句
- 直接SQL查询在Magento
- Magento 中执行SQL语句.[magento二次开发]
- magento-----直接在phtml中使用静态块----------------强悍!
- Magento 中执行SQL语句.
- WebFocus 中直接使用SQL 语句
- 在Yii中直接使用sql
- 在Symfony中直接运用SQL语句检索数据
- Magento中如何调用SQL语句
- Magento中打印SQL语句来调试
- magento 中查看执行的sql语句
- Android Apps for Absolute Beginners Chapter 01
- jQuery获取--checkbox复选框的值
- 接口和抽象类
- smarty总结
- vmstat 命令详解
- 在Magento中直接使用SQL语句
- 课堂小记
- 用Cucumber脚本做故事驱动开发
- debug
- AIX-HACMP群集系统安装详细步骤
- 做人不要太成熟
- Chrome 离线安装包下载地址
- @awk判断输出----一些不常见的用法@
- 网络驱动移植之解析Linux网络驱动的基本框架