[thinkphp] Basic Guide

Source: Internet
Author: User
Tags dsn php tutorial
Separate groups:

Apps, each grouping is completely independent, including models, controllers, views, configuration and function files, and so on, can easily implement the grouping of moving and unloading.
The standard stand-alone grouping directory structure is (in the case of a home grouping):

--+ Home Home Group Directory
├-+ Common grouping function directory
├-+ Conf Group configuration directory
├-+ Lang Packet Language Pack directory
├-+ Action Group Action Controller Directory
├-+ Model grouping Models Catalog
├-+ Widget Group Widget directory
├-+ ORG Group Extension Class Library directory
├-+ ... Other Hierarchical catalogs
└-+ TPL Group Template directory

thinkphp Output model and configuration

I. Output of thinkphp 3 (emphasis)

A, through the Echo and other PHP native output mode in the page output

B. Output via Display method

You can use the Assign method to assign variables

C, modify the left and right delimiters

Hugh to modify a configuration item in a configuration file

' Tmpl_l_delim ' = ' <{',//modify left delimiter

' Tmpl_r_delim ' = '}> ',//Modify right delimiter

Ii. model use of thinkphp 3 (emphasis)

You need to manipulate the database in a method by using the new Model (table name)

$m =new Model (' User ');

$arr = $m->select ();

' Db_type ' = ' mysql ',//Set Database type

' db_host ' = ' localhost ',//Set host

' Db_name ' = ' thinkphp ',//Set database name

' Db_user ' + ' root ',//set user name

' Db_pwd ' + ',//Set Password

' Db_port ' = ' 3306 ',//Set port number

' Db_prefix ' = ' tp_ ',//Set table prefix

You can also configure using the DSN method

' Db_dsn ' = ' mysql://root: @localhost: 3306/thinkphp ',//Configure database information using DSN mode

If both methods are present, the DSN takes precedence

There is also a simple and practical way to model

M () is equivalent to the new Model ();

$m =m (' User ');

$arr = $m->select ();

Using instances of the model can manipulate the data, the operation is generally to the database for the deletion of the search curd

Add-C Create $m->add ()

Delete-D delete $m->delete ()

Change-u Update $m->save ()

Check-R Read $m->select ()

Iii. Supplementary (understanding)

A, the template can traverse the array

<{$vo .id}>----<{$vo .username}>-----<{$vo .sex}>

b, we can open the debug function in the Page_trace

1. Turn on the debug function

3. Turn on Debug mode

Define (' App_debug ', true);

2. We need to set the configuration file to open the page trace

' Show_page_trace ' =>true,//open page TRACE

Configuration:

' Url_pathinfo_depr ' = '-',//Modify the delimiter of the URL

' Tmpl_l_delim ' = ' <{',//modify left delimiter

' Tmpl_r_delim ' = '}> ',//Modify right delimiter

' Db_type ' = ' mysql ',//Set Database type

' db_host ' = ' localhost ',//Set host

' Db_name ' = ' thinkphp ',//Set database name

' Db_user ' + ' root ',//set user name

' Db_pwd ' + ',//Set Password

' Db_port ' = ' 3306 ',//Set port number

' Db_prefix ' = ' tp_ ',//Set table prefix

' Db_dsn ' = ' mysql://root: @localhost: 3306/thinkphp ',//Configure database information using DSN mode

' Show_page_trace ' =>true,//open page TRACE http://w2ks.com/

The above describes the [thinkphp] basic guide, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.