用PHP5進行三層開發_PHP教程

來源:互聯網
上載者:User
原文:http://www.onlamp.com/pub/a/php(做為現在的主流開發語言)/2004/12/09/three_tier.html
Three-Tier Development with php(做為現在的主流開發語言) 5
by Luis Yordano Cruz
12/09/2004

此文示範了php(做為現在的主流開發語言)三層開發的強大功能,PEAR::DB_DataObject用於商務邏輯,Smarty用於顯示邏輯,這裡假設你熟

悉了HTML,Smarty,PEAR::DB_DataObject,MySQL(和PHP搭配之最佳組合)和php(做為現在的主流開發語言)5.如果你需要補充知識,下面的文章解釋了一些原理:

用php(做為現在的主流開發語言) DataObject簡化商務邏輯
Smarty簡介:一個php(做為現在的主流開發語言)模板引擎
php(做為現在的主流開發語言)延展性:Myth

你應該已安裝和配置好了apache(Unix平台最流行的WEB伺服器平台),MySQL(和PHP搭配之最佳組合),和php(做為現在的主流開發語言)5(或者iis(微軟的WEB伺服器平台),MySQL(和PHP搭配之最佳組合)5和php(做為現在的主流開發語言))

PEAR::DB_DataObject
PEAR::DB_DataObject 是一個使用者資料庫訪問的抽象API.它是一個基於PEAR::DB的SQL構建器和資料建模層.它

把資料庫表映射到php(做為現在的主流開發語言)類並且提供像SELECT,INSERT,UPDATE,和DELETE這樣的公用SQL函數.這使即使不了

解SQL的開發人員也可以寫出好的資料庫存取碼,並且鼓勵示範邏輯和商務邏輯有一個清晰的分離.

(DB_OO已經移動到的PEAR,現在是DB_DataObject,如果你有老的代碼要更新,查看關於從老的db_oo代碼更新到

DB_DataObjects的注釋).

相關閱讀

Upgrading to php(做為現在的主流開發語言) 5
By Adam Trachtenberg

Table of Contents
Index
Sample Chapter

Read Online--Safari Search this book on Safari:

Only This Book All of Safari
Code Fragments only
DataObject performs two tasks. First, it builds SQL statements based on the objects variables and the builder

methods. Second, it acts as a datastore for a table row. Theres a core class, which you extend for each of

your tables so that you put the data logic inside the data classes. Theres also an included Generator to make

your configuration files and your base classes.

DataObject 執行兩個任務.第一,它構建基於物件變數的SQL語句和構建器方法.第二,它作為資料庫表的資料存

儲.這裡有個核心類,對於每個表繼承它,以使你把資料邏輯放入資料類中.這裡還包括一個產生器,


DataObject 極大的簡化了資料庫存取碼,它使開發大型的,資料驅動的網站更加容易.

At present, Alan Knowles, the lead developer of PEAR::DB_DataObject, is working on a new project called DBDO,

a C implementation of the PEAR package DB_DataObjects, based on libgda. His goal is to create the next

generation of PEAR::DB_DataObjects.

SMARTY

Smarty是一個從web頁示範中分離內容的php(做為現在的主流開發語言)模板引擎.它使用GPL許可.

Large projects commonly separate the role of the graphic designer from that of the programmer. However,

programming in php(做為現在的主流開發語言) has the tendency to combine those two roles in a person and inside the code. This can bring

difficulties when it comes time to change some part of the pages design. If the page mixes content and

presentation, the developer has to crawl through the program to find the presentation. Smarty helps to solve

this problem.

Combining the Two
The first thing to do when starting this project is to create a workspace in which to store the projects code.

Then its time to configure PEAR::DB_DataObject to connect to the MySQL(和PHP搭配之最佳組合) database MySQL(和PHP搭配之最佳組合) (name: example),

map the database tables to php(做為現在的主流開發語言) classes, and then configure Smarty for the presentation tier for the user. Here

are those steps in more detail:


建立工作環境

建立一個叫做dataobjects的目錄.

從命令列安裝PEAR::DB_DataObject,鍵入:
>pear install Date

http://www.bkjia.com/PHPjc/508712.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508712.htmlTechArticle原文:http://www.onlamp.com/pub/a/php (做為現在的主流開發語言) /2004/12/09/three_tier.html Three-Tier Development with php (做為現在的主流開發語言) 5 by Luis...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.