I found some ideas and techniques to use thinkphp to share with you
It's not even mentioned in some manuals.
Agreed:
1. All class library files must use the. class.php as the file suffix, and the class name and file name remain the same
2. Controller class name with http://www.aliyun.com/zixun/aggregation/16339.html ">action" as suffix
3. The class name of the model is suffix, the first letter of the class name must be capitalized
4. database table names are all lowercase,
As:
Data table Name: prefix _ table name
Model Class Name: Table name Model NOTE: This is the first letter of the table name to be capitalized
Create object: D (' table name ') Note: Here's the first letter of the table name to capitalize
Defining controller Classes
Class Indexaction extends action{
Public function Show () {
Echo ' This is the new show operation ';
}
}
And then enter it in the browser.
http://localhost/myApp/index.php/Index/show/
To define a model class:
Class table name Model extends model{
[///manually define fields [optional]
Protected $fields = Array (
' ID ',
' Username ',
' Email ',
' Age ',
' _PK ' => ' id ',//primary key
' _autoinc ' =>true//self-increasing
)
]
}
Changes to records:
$User = D ("user")//Instantiate User Object
$User->find (1)//Find a record with ID 1
$User->name = ' thinkphp '//Change the Name field of the found record to thinkphp
$User->save ()//Save modified data
Update values for specific fields
$User->setfield (' name ', ' Topthink ', ' id=1 ')
You can also support operations on fields
$User->setfield (' Score ', ' (score+1) ', ' id=1 ')