Magento中如何调用SQL语句
来源:互联网 发布:php 调用js 编辑:程序博客网 时间:2024/04/30 02:37
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打印?
- <?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/>";
- }
- }
- }?>
<?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
- Magento中如何调用SQL语句
- Magento中如何调用SQL语句------magento----摘来的其他不错的!
- magento -- 在Magento中获取SQL语句
- Magento 中执行SQL语句.[magento二次开发]
- Magento 中执行SQL语句.
- magento -- 在Magento中使用自己写的SQL语句
- Magento中打印SQL语句来调试
- Magento中直接使用SQL语句
- 在Magento中直接使用SQL语句
- magento 中查看执行的sql语句
- Magento中直接使用SQL语句
- magento中打印运行的SQL语句
- magento 中 直接写sql语句
- Magento中打印SQL语句来调试
- magento -- 在magento中如何调用static block?
- 在magento中如何调用static block
- 在magento中如何调用static block?
- magento 输出sql语句
- Magento运行出现错误的解决方法
- Fatal error: Maximum execution time of 60 seconds exceeded in
- Magento后台添加产品首页显示不了的解决方法
- Servlet多线程机制
- magneto 1.4中产品不在前台显示的四大因素
- Magento中如何调用SQL语句
- 双硬盘装Linux+WinXP的曲折经过
- Bestseller products in Magento
- .NET OracleLob 读写操作
- SQLServer 2005中Sa用户可以登录进去,Windows管理员却无法登陆进去
- 高端人才必看,生意人必读!
- 自动化测试 - RFT系列教程9:最复杂的控件:TABLE(二) 表格的行数是不确定的
- ifconfig 源码分析
- 块设备