用php5进行三层开发

原文:http://www.onlamp.com/pub/a/php(做为现在的主流开发语言)/2004/12/09/three_tier.htmlthree-tier development with php(做为现在的主流开发语言) 5by luis yordano cruz12/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_dataobjectpear::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(做为现在的主流开发语言) 5by adam trachtenberg

table of contentsindexsample chapter

read online–safari search this book on safari: only this book all of safaricode 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 twothe 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…

Posted in 未分类