PHP simple MVC (like C # MVC) solution

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.