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');
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/>";
- }
- }
- }?>
Royal Room
Standard Room
/******************获取当前路径************************/
$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');
if(is_null($urlPart)) {
$urlPart = $urlRequest->getServer('PATH_INFO');
}
$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
/******************获取当前路径************************/
$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');
if(is_null($urlPart)) {
$urlPart = $urlRequest->getServer('PATH_INFO');
}
$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
/******************获取当前路径************************/
No comments:
Post a Comment