Thinkphp学习笔记
Thinkphp学习笔记
一、入口index.php
- <?php
- require './ThinkPHP/ThinkPHP.php';
- ?>
二、配置Conf/config.php
- <?php
- return array(
-
- 'DB_TYPE' => 'mysql',
- 'DB_HOST' => 'localhost',
- 'DB_NAME' => '',
- 'DB_USER' => '',
- 'DB_PWD' => '',
- 'DB_PORT' => '3306',
- 'DB_PREFIX' => '',
- 'APP_DEBUG' => true,
- 'TOKEN_ON' => true,
- 'URL_MODEL' => 1,
-
-
- 'DB_FIELD_CACHE'=>false,
- 'HTML_CACHE_ON'=>false,
- );
- ?>
三、模板使用
结构图
- ├─Down
- │ index.html
- │
- ├─Game
- │ index.html
- │
- ├─Index
- │ index.html
- │
- ├─LineGame
- │ index.html
- │
- ├─Public
- │ footer.html
- │ top.html
- │
- └─Video
- index.html
1、根目录Public文件夹
__PUBLIC__
网址
__ROOT__
2、引用公用的模板文件
<include file="Public:top" />引用的是Tpl\Public\top.html
<include file="Public:footer"/>
四、系统文件
1、Lib\Action\IndexAction.class.php
执行的是模板Tpl\Index\index.html
遵循的原则是在哪个函数里执行就用哪个函数对应的模板
- <?php
-
- class IndexAction extends Action {
- public function index(){
-
- $video = M( 'video' );
- $re=$video->where("id>=1 && id<=10")->select();
- $this->assign('listvideo',$re);
-
- $down = M( 'down' );
- $re=$down->select();
- $this->assign('listdown',$re);
-
- $lm = M( 'lm' );
- $re=$lm->where("id>=1&&id<=10")->select();
- $this->assign('listlm',$re);
-
- $jc = M( 'jc' );
- $re=$jc->where("id>=1&&id<=10")->select();
- $this->assign('listjc',$re);
-
- $this->display();
- }
- }
列表及分页
- <?php
-
- class VideoAction extends Action {
- public function index(){
-
- $video = M( 'video' );
- import("ORG.Util.Page");
- $count = $video->count();
- $p = new Page($count, 10);
- $list = $video->limit($p->firstRow . ',' . $p->listRows)->order('id desc')->select();
-
- $p->setConfig('header', '条数据');
- $p->setConfig('prev', "\<IMG src=\"__PUBLIC__\/image\/lt.gif\" align=absMiddle\>");
- $p->setConfig('next', "\<IMG src=\"__PUBLIC__\/image\/gt.gif\" align=absMiddle\>");
- $p->setConfig('first', '<<');
- $p->setConfig('last', '>>');
- $page = $p->show();
- $this->assign("page", $page);
- $this->assign("listvideo", $list);
- $this->assign('count',$count);
-
- $lm = M( 'lm' );
- $re=$lm->where("id>=1&&id<=10")->select();
- $this->assign('listlm',$re);
-
- $jc = M( 'jc' );
- $re=$jc->where("id>=1&&id<=10")->select();
- $this->assign('listjc',$re);
-
- $this->display();
- }
- }