Magento中如何调用SQL语句

如何调用SQL语句

让我们在系列文章I的基础上完成本文内容.

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:

    <?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

评论

The home loans are essential

The home loans are essential for guys, which want to organize their career. In fact, it's not really hard to get a financial loan.

If you try to find place

If you try to find place where you can buy term paper or buy research paper here is very proficient place for you about essays writing, which keep examples and gives an excuse to learn how make research . But this site is more alluring, and more cooperative. So don't be lazy and write your own or buy custom essay papers about this topic. Thanks.

It is known that cash can

It is known that cash can make people free. But how to act if somebody has no cash? The one way is to receive the lowest-rate-loans.com or sba loan.

希望更详细点

希望更详细点

谢谢分享<a

谢谢分享<a href='http://www.cnmagento.com'>magento</a>  这里也有不少好的magento教程