Thinkphp summary, thinkphp
After using ThinkPHP for several projects, I feel that this framework is quite good and suitable for my logic habits. It is also quick to develop. I have summarized some of the frequently used projects, hope to help beginners TP!
1. tags not available in the template
{$ Content} {$ I}
2. If tag
For example: <if condition = "$ name eq 1">
There are always unexpected errors after the test, so it is better to use them directly <? Php if (...) {...?> Faster.
Conventions:
1. All class library files must use. class. php as the file suffix, and the class name and file name must be consistent.
2. The class name of the controller is suffixed with Action.
3. The Model class name is suffixed with Model. The first letter of the class name must be capitalized.
4. All database table names are in lower case,
For example:
Data Table Name: prefix _ table name
Model Class Name: Table Name Model note: the first letter of the table name must be capitalized.
Create object: D ('table name') Note: The first letter of the table name must be capitalized.
Define controller class
Class IndexAction extends Action {
Public function show (){
Echo 'this is the new show operation ';
}
}
Enter
Http: // localhost/myApp/index. php/Index/show/
Define model class:
Class table name Model extends Model {
[// Manually define a field [Optional]
Protected $ fields = array (
'Id ',
'Username ',
'Email ',
'Age ',
'_ PK' => 'id', // primary key
'_ Autoinc' => true // whether to auto-Increment
)
]
}
Record modification:
$ User = D ("User") // instantiate the User object
$ User-> find (1) // search for records with id 1
$ User->