Thinkphp Study Notes 1. entry index. php & lt ;? Phprequire & amp; #39;./ThinkPHP. php & amp; #39 ;;? & Gt; 2. configure Conf/config. php & lt ;? Phpreturnarray (// & amp; #39;...
Thinkphp study notes
I. entry index. php
-
- Require './ThinkPHP. php ';
- ?>
2. configure Conf/config. php
-
- Return array (
- // 'Config maps '=> 'configuration value'
- 'Db _ type' => 'mysql', // Database TYPE used
- 'Db _ host' => 'localhost ',
- 'Db _ name' => '', // database NAME
- 'Db _ user' => '', // access the database account
- 'Db _ pwd' => '', // Access database password
- 'Db _ port' => '123 ',
- 'Db _ prefix' => '', // table PREFIX
- 'App _ debug' => true, // DEBUG mode switch
- 'Token _ on' => true, // whether to enable TOKEN verification
- 'URL _ model' => 1, // URL mode: 0 Normal Mode 1 PATHINFO 2 REWRITE 3 Compatible Mode
- // 'Show _ PAGE_TRACE '=> true,
- // 'App _ debug' => true,
- 'Db _ FIELD_CACHE '=> false,
- 'HTML _ CACHE_ON '=> false,
- );
- ?>
III. template usage
Structure chart
- Failover-Down
- │ Index.html
- │
- Alibaba-Game
- │ Index.html
- │
- ├ ── Index
- │ Index.html
- │
- ├ ── LineGame
- │ Index.html
- │
- ─ ── Public
- │ Footer.html
- │ Top.html
- │
- └ ── Video
- Index.html
1. Public folder in the root directory
_ PUBLIC __
URL
_ ROOT __
2. reference a common template file
References Tpl \ Public \ top.html
IV. system files
1. Lib \ Action \ IndexAction. class. php
The template Tpl \ Index \ index.html is executed.
The principle is that the template corresponding to the function is used for execution in which function
-
- // This class is automatically generated by the system for testing purposes only
- Class IndexAction extends Action {
- Public function index (){
- // Listvideo
- $ Video = M ('video'); // instantiate the model class
- $ Re = $ video-> where ("id >=1 & id <= 10")-> select (); // search
- $ This-> assign ('listvideo', $ re );
- // Listdown
- $ Down = M ('low'); // instantiate the model class
- $ Re = $ down-> select ();
- $ This-> assign ('listlow', $ re );
- // Lm
- $ Lm = M ('LM '); // instantiate the model class
- $ Re = $ lm-> where ("id >=1 & id <= 10")-> select (); // search
- $ This-> assign ('listlm ', $ re );
- // Listjc
- $ Jc = M ('JC'); // instantiate the model class
- $ Re = $ jc-> where ("id >=1 & id <= 10")-> select (); // search
- $ This-> assign ('listjc', $ re );
- // Display
- $ This-> display ();
- }
- }
List and paging
-
- // This class is automatically generated by the system for testing purposes only
- Class VideoAction extends Action {
- Public function index (){
- // Listvideo
- $ Video = M ('video'); // instantiate the model class
- Import ("ORG. Util. Page"); // import the paging class
- $ Count = $ video-> count (); // calculates the total number.
- $ P = new Page ($ count, 10 );
- $ List = $ video-> limit ($ p-> firstRow. ','. $ p-> listRows)-> order ('Id desc ')-> select ();
- // $ P-> firstRow the subscript of the start record on the current page, $ p-> listRows the number of records per page
- $ P-> setConfig ('header', 'item data ');
- $ P-> setConfig ('prev ',"\");
- $ P-> setConfig ('next ',"\");
- $ P-> setConfig ('first', '<');
- $ P-> setConfig ('last', '> ');
- $ Page = $ p-> show (); // output variable of the navigation bar on the page
- $ This-> assign ("page", $ page );
- $ This-> assign ("listvideo", $ list); // data loop variable
- $ This-> assign ('count', $ count );
- // Lm
- $ Lm = M ('LM '); // instantiate the model class
- $ Re = $ lm-> where ("id >=1 & id <= 10")-> select ();
- $ This-> assign ('listlm ', $ re );
- // Listjc
- $ Jc = M ('JC'); // instantiate the model class
- $ Re = $ jc-> where ("id >=1 & id <= 10")-> select ();
- $ This-> assign ('listjc', $ re );
- // Display
- $ This-> display ();
- }
- }