Magento中如何调用SQL语句------magento----摘来的其他不错的!

 

1.Magento运行出现错误的解决方法 

 

Magento根目录下的lib/Varien/Simplexml中的config.php文件,在顶段加上error_reportting(0);来屏蔽php的错误或异常捕捉就行了,不过,只是在Warning提示时才好用,如果时Error的话建议另辟蹊径

 

 

2.How to get currency symbol? 

 

Here’s another way that might work for you:

 

    Mage::app()->getLocale()->currency(Mage::app()->getStore()->

    getCurrentCurrencyCode())->getSymbol()

 

 

or if you want to pass a certain currency code simply specify it:

 

    Mage::app()->getLocale()->currency(’EUR’)->getSymbol()

 

 

3.核心类的详细介绍

http://freegento.com/doc/d0/d58/class_varien___object.html

 

4

 

magento connect manage出现404或者500内部错误的解决办法 

 

Directory /downloader/ set to 755

file /downloader/index.php set to 644 

 

 

5

 

后台产品页显示产品缩略图的插件 

 

Key:magento-community/TBT_Enhancedgrid-1.2

 

 

6

 

magento不错的博客地址:

http://blog.csdn.net/xinhaozheng/category/524202.aspx

 

 

 

7

 

Magento中如何调用SQL语句 

 

I 创建表结构和测试数据

 

create table rooms(id int not null auto_increment, name varchar(100), primary key(id));

 

insert into rooms values(1,'Royal Room');

 

insert into rooms values(2,'Standard Room');

 

II.创建 controllers/RoomController.php:

 

 

 

源码copy to clipboard打印?

 

 

 

   1. <?php   

   2.     class Cartz_Hotel_RoomController extends Mage_Core_Controller_Front_Action{   

   3.        public function listingAction() {   

   4.           $handle = Mage::getSingleton('core/resource')->getConnection('core_write');   

   5.   

   6.           $query  = $handle->query('select name from rooms');   

   7.           while ($row = $query->fetch()) {   

   8.              $row = new Varien_Object($row);   

   9.              echo "<strong>" . $row->getName() . "</strong><br/>";   

  10.           }   

  11.   

  12.        }   

  13. }?>  

 

<?php class Cartz_Hotel_RoomController extends Mage_Core_Controller_Front_Action{

    public function listingAction() {

   $handle = Mage::getSingleton('core/resource')->getConnection('core_write');

$query = $handle->query('select name from rooms');

while ($row = $query->fetch()) {

$row = new Varien_Object($row);

echo "<strong>" . $row->getName() . "</strong><br/>";

}

}

}

?>

 

在地址栏中输入: http://localhost/magento/index.php/hotel/room/listing, 页面将输出:

 

 

 

Royal Room

 

 

 

Standard Room

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值