PHP simple MVC (like C # MVC) Controllers: HomeController. php, ShopController. php .... views: Homeindex, Homelist .... access path: 127.0.0.1index.phphomeindex127.0.0.1index.phphomelis PHP simple MVC (like C # MVC)
Controllers: HomeController. php, ShopController. php ....
Views: Home/index, Home/list ....
Access path:
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
/* Mall controller */
Class HomeController extends BaseController
{
// Wind Vane
Public function biao (){
$ This-> cacheView (); // outputs data from the cache first. optional values: Database cache and static disk cache pages.
$ Site = $ this-> dal ('site'); // call the database layer
// Category
$ Cats = $ site-> getMyCats ('weathervane ');
// List
Foreach ($ cats as & $ cat ){
$ Cat ['list'] = $ site-> getMyProductTop ("where cid =". $ cat ['id'], 5 );
}
$ This-> viewData ['Cats'] = $ cats; // assign a variable to the view template
$ This-> view (); // Display view
}
}
?>
Template syntax (smarty ):
You are viewing {$ cat. name} popular items
{Section name = a loop = $ list }}
{Assign var = 'product' value = $ list [a]}
{$ Product. title | strip_tags | truncate_cn: 20 }}
¥ {$ Product. price }}
{/Section }}
Reference cases:
Amoy: http://www.taodao100.com
------ Solution --------------------
How do you specify mssql?
Use pdo as the base class
I have a new article
---------------------------------------------
Http://topic.csdn.net/u/20100310/11/62a60067-b3da-4dee-9d6a-f1baeb2f3f33.html