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

WBOY
풀어 주다: 2016-06-13 13:42:29
원래의
748명이 탐색했습니다.

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
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!