"Connect database Configuration"
convertion.php
config.php
- Make a database connection configuration in config.php ( Select Content Replication in the convertion.php file, which overrides the convertion.php configuration )
- making model models
A) the model itself is a class file
b) each data table in the database corresponds to a model file
c) simplest data model class ( note namespace, no omissions )
- Field Cache Settings
The TP Framework executes the field information in the data table, the SQL statement can query "show colums from Table" , in performance consideration, can cache the field, avoid each repetition SQL statement.
- The current model model can be personalized according to the situation
- Database tables are prefixed with a more prescriptive design of the database, and avoid the complexity of the code when data tables are accessed
- Define a debug output function in the portal file for easy system development ( can be defined in the index.php Portal file )
" three ways to instantiate the model"
- $goods = new namespace Goodsmodel ();
- $goods = D (' model sign ');
* When instantiating a model object, note the naming of the object, which involves accessing the database table.
a) $goods = D ("goods");
b) The $goods is the object of the parent Model , but the data table of the operation is sw_goods
c) $obj = D (); instantiation of Model object, no specific action data table, and M () method Effect Consistent
- $obj = M ();
A) instantiation of the parent class Model
b) you can directly invoke the properties inside the parent Model to get database related operations
c) Custom model is an empty shell, there is no need to instantiate a custom model
d) $obj = M (' Data sheet sign '); instantiation of Model object, the actual operation of the specific data table
$obj = D ( sign );
$obj = D ();
$obj = M ( sign );
$obj = M ();
the difference between the D () and M () methods:
The former is a simplified method for new operation in tp3.1.3 ;
the latter is instantiated in the use of Model Parent Class
both are defined in the function library file thinkphp/common/functions.php
Note: If there is no corresponding model model file class, you can also instantiate the model object directly for Operation
Both the D () and M () methods can be instantiated to manipulate a data table that does not have a specific model class file.
Thinkphp Framework _ Learning 9