Thinkphp study notes

Source: Internet
Author: User
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

  1. Require './ThinkPHP. php ';
  2. ?>

2. configure Conf/config. php

  1. Return array (
  2. // 'Config maps '=> 'configuration value'
  3. 'Db _ type' => 'mysql', // Database TYPE used
  4. 'Db _ host' => 'localhost ',
  5. 'Db _ name' => '', // database NAME
  6. 'Db _ user' => '', // access the database account
  7. 'Db _ pwd' => '', // Access database password
  8. 'Db _ port' => '123 ',
  9. 'Db _ prefix' => '', // table PREFIX
  10. 'App _ debug' => true, // DEBUG mode switch
  11. 'Token _ on' => true, // whether to enable TOKEN verification
  12. 'URL _ model' => 1, // URL mode: 0 Normal Mode 1 PATHINFO 2 REWRITE 3 Compatible Mode
  13. // 'Show _ PAGE_TRACE '=> true,
  14. // 'App _ debug' => true,
  15. 'Db _ FIELD_CACHE '=> false,
  16. 'HTML _ CACHE_ON '=> false,
  17. );
  18. ?>

III. template usage

Structure chart

  1. Failover-Down
  2. │ Index.html
  3. Alibaba-Game
  4. │ Index.html
  5. ├ ── Index
  6. │ Index.html
  7. ├ ── LineGame
  8. │ Index.html
  9. ─ ── Public
  10. │ Footer.html
  11. │ Top.html
  12. └ ── Video
  13. 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

  1. // This class is automatically generated by the system for testing purposes only
  2. Class IndexAction extends Action {
  3. Public function index (){
  4. // Listvideo
  5. $ Video = M ('video'); // instantiate the model class
  6. $ Re = $ video-> where ("id >=1 & id <= 10")-> select (); // search
  7. $ This-> assign ('listvideo', $ re );
  8. // Listdown
  9. $ Down = M ('low'); // instantiate the model class
  10. $ Re = $ down-> select ();
  11. $ This-> assign ('listlow', $ re );
  12. // Lm
  13. $ Lm = M ('LM '); // instantiate the model class
  14. $ Re = $ lm-> where ("id >=1 & id <= 10")-> select (); // search
  15. $ This-> assign ('listlm ', $ re );
  16. // Listjc
  17. $ Jc = M ('JC'); // instantiate the model class
  18. $ Re = $ jc-> where ("id >=1 & id <= 10")-> select (); // search
  19. $ This-> assign ('listjc', $ re );
  20. // Display
  21. $ This-> display ();
  22. }
  23. }

List and paging

  1. // This class is automatically generated by the system for testing purposes only
  2. Class VideoAction extends Action {
  3. Public function index (){
  4. // Listvideo
  5. $ Video = M ('video'); // instantiate the model class
  6. Import ("ORG. Util. Page"); // import the paging class
  7. $ Count = $ video-> count (); // calculates the total number.
  8. $ P = new Page ($ count, 10 );
  9. $ List = $ video-> limit ($ p-> firstRow. ','. $ p-> listRows)-> order ('Id desc ')-> select ();
  10. // $ P-> firstRow the subscript of the start record on the current page, $ p-> listRows the number of records per page
  11. $ P-> setConfig ('header', 'item data ');
  12. $ P-> setConfig ('prev ',"\");
  13. $ P-> setConfig ('next ',"\");
  14. $ P-> setConfig ('first', '<');
  15. $ P-> setConfig ('last', '> ');
  16. $ Page = $ p-> show (); // output variable of the navigation bar on the page
  17. $ This-> assign ("page", $ page );
  18. $ This-> assign ("listvideo", $ list); // data loop variable
  19. $ This-> assign ('count', $ count );
  20. // Lm
  21. $ Lm = M ('LM '); // instantiate the model class
  22. $ Re = $ lm-> where ("id >=1 & id <= 10")-> select ();
  23. $ This-> assign ('listlm ', $ re );
  24. // Listjc
  25. $ Jc = M ('JC'); // instantiate the model class
  26. $ Re = $ jc-> where ("id >=1 & id <= 10")-> select ();
  27. $ This-> assign ('listjc', $ re );
  28. // Display
  29. $ This-> display ();
  30. }
  31. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.