网站建设资讯

NEWS

网站建设资讯

phpmvc通用数据库 php中数据库怎么设计

求php zf mvc中数据库层的合理架构方案

看到你前面几段写的就知道你是玩Java的。Java主要用Spring来实现主要的解耦功能。

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了浪卡子免费建站欢迎大家使用!

PHP这里的框架很少,而且PHP也没有那么灵活的反射机制等吧。所以如果要用PHP来实现高内聚低耦合,有点难度,除非你自己搞框架。

我看discuz论坛都没有用那么复杂的技术,而且我个人觉得PHP用MVC来分,分个controller,实在没有必要。

如果楼主用了很复杂的业务逻辑,为何不用Java来做业务中心,PHP做前端,使用Java的WebService来暴露数据呢?

个人拙见,一起探讨。

ASP.NET,VS2010,SQL,PHP,Access,LINQ,MVC等等是什么关系啊??!!!求解答!!!

asp.net一种编写网站或者软件的语言

vs2010可以编写asp.net

sql

是数据库

php是另外一种编写网站的语言

access和sql一样

两种都是数据库

但是acess相对sql比较小

linq是一种通用数据库语法

asp.net下的

可以通用各种数据库

mvc是三层架构

可以进行多人编写

再看看别人怎么说的。

php怎么实现mvc?

MVC三个字母的含义:

M:Model 模型,负责数据库操作。

V:View 视图,负责调用Model调取数据,再调用模板,展示出最终效果。

C:Controller 控制器,程序的入口,决定改调用哪个View,并告诉View该做什么。

下面是一个超级简单的MVC结构实现:

Controller.php

include 'Model.php';

include 'View.php';

class Controller {

private $model     = '';

private $view     = '';

public function Controller(){

$this-model    =    new Model();

$this-view        =    new View();

}

public function doAction( $method = 'defaultMethod', $params = array() ){

if( empty($method) ){

$this-defaultMethod();

}else if( method_exists($this, $method) ){

call_user_func(array($this, $method), $params);

}else{

$this-nonexisting_method();

}

}

public function link_page($name = ''){

$links = $this-model-getLinks();

$this-view-display($links);

$result = $this-model-getResult($name);

$this-view-display($result);

}

public function defaultMethod(){

$this-br();

echo "This is the default method. ";

}

public function nonexisting_method(){

$this-br();

echo "This is the noexisting method. ";

}

public function br(){

echo "br /";

}

}

$controller = new Controller();

$controller-doAction('link_page', 'b');

$controller-doAction();

Model.php

class Model {

private $database = array(

"a"    =    "hello world",

"b"    =    "ok well done",

"c"    =    "good bye",

);

//@TODO connect the database

//run the query and get the result

public function getResult($name){

if( empty($name) ){

return FALSE;

}

if( in_array($name, array_keys( $this-database ) ) ){

return $this-database[$name];

}

}

public function getLinks(){

$links = "a href='#'Link A/anbsp;nbsp;";

$links.= "a href='#'Link B/anbsp;nbsp;";

$links.= "a href='#'Link C/anbsp;nbsp;";

return $links;

}

}

View.php

class View {

public function display($output){

//        ob_start();

echo $output;

}

}


网站栏目:phpmvc通用数据库 php中数据库怎么设计
当前URL:http://cdweb.net/article/dddpcph.html