作者:mobiledu2502927067 | 来源:互联网 | 2014-06-12 18:37
Thinkphp学习笔记一、入口index.php<?phprequire'./ThinkPHP/ThinkPHP.php';?>二、配置Conf/config.php<?phpreturnarray(//'配...
Thinkphp学习笔记
一、入口index.php
- require &#39;./ThinkPHP/ThinkPHP.php&#39;;
- ?>
二、配置Conf/config.php
- return array(
-
- &#39;DB_TYPE&#39; => &#39;mysql&#39;,
- &#39;DB_HOST&#39; => &#39;localhost&#39;,
- &#39;DB_NAME&#39; => &#39;&#39;,
- &#39;DB_USER&#39; => &#39;&#39;,
- &#39;DB_PWD&#39; => &#39;&#39;,
- &#39;DB_PORT&#39; => &#39;3306&#39;,
- &#39;DB_PREFIX&#39; => &#39;&#39;,
- &#39;APP_DEBUG&#39; => true,
- &#39;TOKEN_ON&#39; => true,
- &#39;URL_MODEL&#39; => 1,
-
-
- &#39;DB_FIELD_CACHE&#39;=>false,
- &#39;HTML_CACHE_ON&#39;=>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、引用公用的模板文件
引用的是Tpl\Public\top.html
四、系统文件
1、Lib\Action\IndexAction.class.php
执行的是模板Tpl\Index\index.html
遵循的原则是在哪个函数里执行就用哪个函数对应的模板
-
- class IndexAction extends Action {
- public function index(){
-
- $video = M( &#39;video&#39; );
- $re=$video->where("id>=1 && id<=10")->select();
- $this->assign(&#39;listvideo&#39;,$re);
-
- $down = M( &#39;down&#39; );
- $re=$down->select();
- $this->assign(&#39;listdown&#39;,$re);
-
- $lm = M( &#39;lm&#39; );
- $re=$lm->where("id>=1&&id<=10")->select();
- $this->assign(&#39;listlm&#39;,$re);
-
- $jc = M( &#39;jc&#39; );
- $re=$jc->where("id>=1&&id<=10")->select();
- $this->assign(&#39;listjc&#39;,$re);
-
- $this->display();
- }
- }
列表及分页
-
- class VideoAction extends Action {
- public function index(){
-
- $video = M( &#39;video&#39; );
- import("ORG.Util.Page");
- $count = $video->count();
- $p = new Page($count, 10);
- $list = $video->limit($p->firstRow . &#39;,&#39; . $p->listRows)->order(&#39;id desc&#39;)->select();
-
- $p->setConfig(&#39;header&#39;, &#39;条数据&#39;);
- $p->setConfig(&#39;prev&#39;, "\
");
- $p->setConfig(&#39;next&#39;, "\
");
- $p->setConfig(&#39;first&#39;, &#39;<<&#39;);
- $p->setConfig(&#39;last&#39;, &#39;>>&#39;);
- $page = $p->show();
- $this->assign("page", $page);
- $this->assign("listvideo", $list);
- $this->assign(&#39;count&#39;,$count);
-
- $lm = M( &#39;lm&#39; );
- $re=$lm->where("id>=1&&id<=10")->select();
- $this->assign(&#39;listlm&#39;,$re);
-
- $jc = M( &#39;jc&#39; );
- $re=$jc->where("id>=1&&id<=10")->select();
- $this->assign(&#39;listjc&#39;,$re);
-
- $this->display();
- }
- }