http://blog.sina.com.cn/phpx[订阅]
个人资料
分类
    内容读取中…
评论
读取中...
PHP网站
【翻译】使用PHP5
暂无内容。
访客
读取中...
好友
读取中...
博文
sdfsdfsf(2008-09-04 14:27)
 好久没来了,还是以前那几篇老文,呵呵。
 最近做DISCUZ的二次开发,有些东西需要记录一下,此篇即为DISCUZ数据结构,记录下好时时查看
 
Discuz! 数据库结构参考
总表===>>
各表概述
cdb_access--当某用户对某些版块有特定的权限的时候,该表记录了该用户在这些版块有什么权限。
cdb_admingroups--管理模组信息表
cdb_adminsessions--后台管理登录记录
cdb_announcements--论坛公告信息
cdb_attachments--附件信息表
cdb_attachtypes--附件的所性类型(即后台的附件类型设置,如果没有设置,默认为空。)
cdb_banned--IP禁止信息表
cdb_bbcodes--Discuz!代码信息表
cdb_buddys--会员的好友列表
cdb_caches--统计页面的缓存
cdb_failedlogins--非法登录后台的记录
cdb_favorites--记录用户收藏主题的相关信息
cdb_forumlinks--联盟论坛
cdb_forums--论坛版块信息表
cdb_karmalog--用户评分记录
cdb_members--论坛所有会员主信息表
cdb_onlinelist--在线会员信息
The View
视图


Just like the Model, there are several different ways of doing the View part of our MVC system. We could use the Router to automatically load another file called something like 'view_{name}.php', but to keep this tutorial simple, we'll create a custom Template class, which can be used to show templates.
和Model类似,有很多种不同的方法可以编写我们MVC系统中的View部分。我们可以使用Route来自动地载入那些按’view_{name}.php’(格式命名)的文件,但是为了保持这篇导读能简单,我们将创建一个可以用来显示模板的个人Template类

First, create a new file called 'template.php' in the 'classes' directory, and put the following code in it:
首先,在’classes’目录下新建一个’template.php’文件,再把以下代码写入此文件:

CODE:
The Controller
控制器


The controller part of our MVC system is actually very simple, and requires very little work. First, make sure that the 'controllers' directory exists. Then, create a new file called 'controller_base.php' in the 'classes' directory, and put the following code in it:
我们MVC系统里的controller部分事实上非常的简单,而且只需要很少的一点工作。首先,确定’controllers’目录存在,然后在’classes’目录下新建一个名叫’controller_base.php’文件,再把下面的代码写入此文件:

The Router class 

Router

Our Router class will have to analyze the request, and then load the correct command. First step is to create a basic skeleton for the router class:

我们的Router类将要解析请求,然后载入正确的明亮。第一步是创建Router类的基本框架:

<?php

Class Router {
        private $registry;
private $path;
        private $args = array();

        function __construct($registry) {
                $this->registry = $registry;
             

}

?>

And then add the following lines to the index.php file:

然后在index.php文件中加入下面几行代码:

# Load router
$router = ne

The Model
模型

The 'M' or model part of the MVC system is responsible for querying the database (or another external source) and providing the data to the controller. We could have the appropriate model loaded depending on the request, but I prefer to blur the lines between the model and the controller, whereby the controller uses a DB abstraction library to directly query the DB, instead of having a separate model. You might want to do it differently, but this is a personal preference.
MVC系统的’M’或者’model’部分是负责查询数据库(或者其他外部资源)来提供数据给控制器的。我们可以依靠请求载入恰当的模型,但是我宁愿使模型和控制器之间的界限变模糊,靠控制器使用一个数据库抽象库直接查询数据库来替代一个单独的模型。你可以用不同的方式来做,但这是(我)个人的喜好。

One thing we must do is add the code necessary to setup up a connection with the database, and add it to our index page. There are many great DB abstraction librar
 Creating the Registry class
创建Registry类


The Registry class is used to pass global data around between the individual objects, and is actually a really simple class, and needs no more than three small methods.
Registry类是用来在各个对象间串联起全局数据,而且事实上它是一个很简单的类,只需要不超过3个小方法(即可)。

First, create a new directory called 'classes', and then create a new file called 'registry.php'. Put the following code in the registry.php file:
首先,新建一个名叫’classes’的目录,再新建个名叫’registry.php’的文件。将以下代码加入registry.php文件中。

 小弟我英文比较差劲,为了锻炼英文水平,以后好看国外的文章,我鼓起勇气翻译了以下这篇文章,我已经有心里准备了,砖头都向我脸上来吧~~:lol
现在只翻译完2/3,可是发现我内心十分激动,就先将翻译完的发上来,希望能给英文比我还差的人有点帮助,如果觉得我翻译不好的地方,请跟帖往死里砸,我早就做好暴尸荒野的准备了


作者:我想写,可是发现那个网站上没有。。。不知道会不会告我。。
原文地址:http://www.phpit.net/article/simple-mvc-php5/
译者:Dreamblaze
Blog:http://blog.sina.com.cn/phpx/
Email/MSN:colacc2000@hotmail.com

Building a simple MVC system with PHP5 使用PHP5构建一个简单的MVC系统
Abstract  
摘要

In this t
    在手册里是这样介绍__FILE__的:
    文件的完整路径和文件名。如果用在包含文件中,则返回包含文件名。自 PHP 4.0.2 起,__FILE__ 总是包含一个绝对路径,而在此之前的版本有时会包含一个相对路径。
    如果不注意这段话的话,肯定会有些人会说
$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']和__FILE__是一样的,因为都是得到当前文件的路径,这在一些方面是没有错的,但是当本页被其他页面include的话,就完全不一样了。
    比如:
 include.php(此页面在e:/libs/includes/下)

<?PHP

 

歌名:Smells Like Teen Spirit (很著名的曲之一)
        乐队:涅磐

        
歌词:
 
--=Smells Like Teen Spirit=--

Load up on guns and, Bring your friends, It’s fun to lose, And to pretend
She’s over bored, And self assured,Oh no, I know, A dirty word
hello, how low? (x bunch of times)
With the lights out it’s less dangerous
Here we are now, Entertain us
I feel stupid and contagious
Here we are now, Entertain us
A mulatto, An albino, A mosquito, My Libido, Yeah
I’m worse at what I do best,And for this gift I feel blessed