A namespace (mainly for automatic load classes)
* Namespace (equivalent to a virtual directory), in order for the class to have a unified folder to manage (can automatically load ' class '), each file must have a namespace
*TP How to make namespaces:
The *TP framework has an initial namespace (equivalent to the root directory) Thinkphp\libray
* There are also many root namespaces under the initial namespace, which are divided into two main categories:
Root in 1.TP core class (System file)
Under Libray, there are several folders with several roots (all folders are root)
2.APP inside the root (customization file)
The root of the app is named after the module name
Libray folder and the app inside the module folder are virtual in a root folder, this folder is equivalent to "\" (Root)
Second, obtain system constant information
Three, cross-controller call (in one (MainController.class.php) controller call another (logincontroller,class.php) controller inside the method)
1. Build two controllers
Main controller
Login Controller
3 Methods of invocation
three methods show the same result:
2.U method: The full path to the build method
echo U ("module/controller/method (login)");
3. If the cross-module call: $m = A ("Module folder name (e.g. Home)/login"); $m, method name ();
Iv. connecting database configuration and model data layer
1. If you connect to the database, first modify the database configuration: Open the thinkphp file under the Conf under the convention.php file, in this configuration file will need to modify the database configuration data copied to the configuration file you want to use,
Change the field cache to false in information
2. Make model models: the model itself is a class file, each table in the database corresponds to a model file (if there is no special requirement, the file can not be built)
Create a new model class file that corresponds to the Nation table:
To open the Model file, you can copy some of the required table personalization settings from the library\think\model.class.php file:
The personalization of tables copied from the model parent file can be placed in the model file of the built table:
Instantiating a Model object
thinphp namespace, the connection database is the configuration file to be modified, the model data models layer, the cross-controller call, how to obtain system constant information,