The independent grouping function of ThinkPHP looks good, but the official website does not provide detailed examples and instructions. here, according to the actual development process, we will give the php developers the following instructions: 1. the directory structure of the independent group, which is the same as the official description.
The independent grouping function of ThinkPHP looks good, but the official website does not provide detailed examples and instructions. here, according to the actual development process, we will give the php developers the following instructions:
1. directory structure of independent groups
Create a Modules folder and configure config.
Note:The action of an independent group is directly placed in the action Directory, without the lib Directory. this is a subtle difference for me a day.
2. Mutual calls between independent groups
If you create an independent group to specifically process the addition, deletion, modification, and query of data, you will find many miracles when the methods of other groups call the addition, deletion, modification, and query methods of this group, for example, there are various non-existent prompts, and model verification is inexplicably ineffective. This all comes due to the fact that the corresponding module is not automatically loaded !!
Therefore, give up the official A method and load all modules by yourself, for example:
- Import ('action. mcorpworkeraction', APP_PATH. 'Les les/base'); // load the Action of the base module by yourself
- Import ('Model. CorpworkerModel ', APP_PATH. 'Les les/base ');
- // Load the model of the base module by yourself. Otherwise, the methods in the model such as automatic verification will become invalid.
- $ Mworker = new McorpworkerAction (); instantiate the action. Be sure to write it fully.
- $ Worker ["loginname"] = $ _ REQUEST ['loginname'];
- $ Worker ["realname"] = $ _ REQUEST ['realname'];
- $ Worker ["pass"] = mmin ($ _ REQUEST ['pass']);
- // Construct the data and add it
- $ R = $ Mworker-> addfun ($ worker );
- // In this way, you can call the addition, deletion, modification, and query of the Mcorpworker of the base module !!