1
2
3
4
5
6
7
8
9
10
|
网站根目录/ |-自定义模块 |-control 控制器 |-model 模型 |- static 静态文件 |-images |-js |-css |-templates 模块目录 |- default |
1
2
3
4
5
6
7
8
9
10
11
|
//引入重要的文件 require_once (dirname( __file__ )). ‘/../include/common.inc.php‘ ; require_once (DEDEINC. ‘/request.class.php‘ ); //指定了如何请求一个控制器的某个方法 //http://网站/自定义模块/index.php?c=控制器&a=方法 $ct = Request( ‘c‘ , ‘index‘ ); $ac = Request( ‘a‘ , ‘index‘ ); //统一应用程序入口 RunApp( $ct , $ac ); |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
class test extend Control { //方法前面需加上ac_ public function ac_test() { echo ‘测试‘ ; } public function ac_getList() { //通过request()来获取参数 $id = request( ‘id‘ ); //获取模型数据 $data = $this ->Model( ‘elist‘ )->getList(); //分配数据 $GLOBALS [ ‘data‘ ] = $data ; //设置模板 $this ->SetTemplate( ‘showlist.htm‘ ); //显示模板 $this ->Display(); } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class elist extend Model { public function getList() { $sql = ‘select * from dede_test‘ ; $this ->dsql->SetQuery( $sql ); $this ->dsql->Execute(); $rows = array (); while ( $row = $this ->dsql->GetArray()) { $rows [] = $row ; } return $rows ; } } |
1
2
|
<?php foreach ( $data as $k => $v ): ?> <?php endforeach ; ?> |
原文:https://www.cnblogs.com/zhouxiang1989/p/10773195.html