1. in the specific Action method, you can use C () to dynamically configure some parameters, mainly those that are not yet used. The usage is as follows:
1. in the specific Action method, you can use C () to dynamically configure some parameters, mainly those that are not yet used. The usage is as follows:
C ('parameter name'); // Obtain the set parameter value
C ('parameter name', 'New parameter value'); // you can specify a new value.
2. use of D () functions:
Define the model class, such as UserModel, and then use the D () function to operate the data. For example:
First, create a php script named UserModel. class. PHP under "your project" \ Lib \ Model. the content is as follows:
Class UserModel extends Model {}
Then, you can perform the following operations without adding any attributes and methods:
$ User = D ("User"); // instantiate the User object. User is a data table created in the database named "prefix _ user ".
You can also use $ User = new UserModel () instead to instantiate an object.
After instantiation, you can add, delete, query, modify, and perform a series of operations on the data, such:
$ User-> find (1); // query records whose primary key is 1
Use of the 3. S () function:
ThinkPHP abstracts various cache methods into uniform cache classes for calling, and ThinkPHP unifies all cache mechanisms into one S method for operations.
Different caching methods do not need to focus on specific cache details. For example:
S ('data', $ data); // use the Data identifier to cache $ data Data
S ('data', $ data, 3600); // cache $ Data for 3600 seconds
$ Data = S ('data'); // Obtain cached data