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
<?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):
<div id="list">
<h3><span>您正在查看{{$cat.name}}热销商品</span></h3>
<ul>
{{section name=a loop=$list}}
{{assign var='product' value=$list[a]}}
<li>
<a href="{{UrlAction action='myitem' iid=$product.iid}}" title="{{$product.title|strip_tags}}" target="_blank" class="image">
<img src="{{if $product.img!=''}}{{$product.img}}_160x160.jpg{{else}}{{UrlContent url='content/images/nopic.gif'}}{{/if}}" alt="{{$product.title|strip_tags}}" />
</a>
<a href="{{UrlAction action='myitem' iid=$product.iid}}" title="{{$product.title|strip_tags}}" target="_blank" class="title">
{{$product.title|strip_tags|truncate_cn:20}}
</a>
<em>¥{{$product.price}}</em>
</li>
{{/section}}
</ul>
</div>
参考案例:
淘到:http://www.taodao100.com
[解决办法]
你的不是pdo吗,怎么指定mssql
应该使用pdo做基类
我新发了一篇文章
---------------------------------------------
http://topic.csdn.net/u/20100310/11/62a60067-b3da-4dee-9d6a-f1baeb2f3f33.html