PHP简易MVC(仿C#MVC)解决办法

WBOY
Release: 2016-06-13 13:42:29
Original
779 people have browsed it

PHP简易MVC(仿C#MVC)
Controllers:HomeController.php、ShopController.php ....
Views:Home/index、Home/list ....

访问路径:
http://127.0.0.1/index.php/home/index
http://127.0.0.1/index.php/home/list
http://127.0.0.1/index.php/shop/index
.....

HomeController.php

/* 商城控制器 */

class HomeController extends BaseController 
{
//风向标
public function biao(){
$this->cacheView(); //优先从缓存输出,可选数据库缓存/磁盘缓存静态页面

$site=$this->dal('site'); //调用数据库层

//分类
$cats=$site->getMyCats('风向标');

//列表
foreach($cats as &$cat){
$cat['list']=$site->getMyProductTop("where cid=".$cat['id'],5);
}

$this->viewData['cats']=$cats; //给视图模板赋值变量
$this->view(); //显示视图
}

}
?>

模板语法(smarty):


 

您正在查看{{$cat.name}}热销商品


   
 
 

参考案例:
淘到:http://www.taodao100.com



------解决方案--------------------
你的不是pdo吗,怎么指定mssql

应该使用pdo做基类


我新发了一篇文章
---------------------------------------------
http://topic.csdn.net/u/20100310/11/62a60067-b3da-4dee-9d6a-f1baeb2f3f33.html
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template