I. Output of thinkphp 3 (emphasis)
A, through the Echo and other PHP native output mode in the page output
B. You can use the Assign method to output the variable you want to assign by using the Display method
C, modify the left and right delimiter Hugh to modify configuration items in the configuration file ' Tmpl_l_delim ' + ' <{',//Modify the left delimiter ' tmpl_r_delim ' + '}> ',//modify the correct delimiter
Second, thinkphp 3 model use (emphasis) needs to be in the form of New Model (table name) to manipulate the database
$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 use the DSN method to configure ' 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 () 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
Passing data to a template on the action layer
Public Function Index () { $m =new Model (' user '); In config.php configuration $arr = $m->select ();//Var_dump ($arr); $this->assign (' data ', $arr); $this->display (); }
Receiving data traversal at the TPL template layer
<volist name= ' data ' id= ' voc22 ' > <{$voc 22.id}>---<{$voc 22.username}>-----<{$VOC 22.sex} ><br/> </volist>//Outer volist label cannot be modified
b, we can open the debug function in the Page_trace "
1. Turn on the Debug function//Turn on Debug mode define (' App_debug ', true);
2. We need to set config file, open page trace ' show_page_trace ' =>true,//open page trace
thinkphp study 04