Home  >  Article  >  Backend Development  >  Things to note when using ThinkPHP independent groups, thinkphp grouping_PHP tutorial

Things to note when using ThinkPHP independent groups, thinkphp grouping_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:13:12928browse

Notes on using ThinkPHP independent grouping, thinkphp grouping

The examples in this article describe the precautions for using independent groups of ThinkPHP. Share it with everyone for your reference. The details are as follows:

Regarding the independent grouping of ThinkPHP, the function seems to be quite good, but the official has not given detailed examples and instructions. Here, based on the actual development process, I will give you the following instructions for PHP developers:

1. Independently grouped directory structure

Same as the official instructions, create the Modules folder and configure config.

Note: Independently grouped actions are placed directly in the action directory, no lib directory is required (This subtle difference troubled me for a day)

2. Mutual calls between independent groups

If you create an independent group specifically to handle the addition, deletion, modification and query of data, when other grouping methods call the addition, deletion, modification and query method of this group, you will find many miracles, such as various non-existent prompts and inexplicable model verification. Failure, etc., are all attributed to one reason: the corresponding module is not automatically loaded! !

So, give up the official method A and load all the modules yourself, for example:

Copy code The code is as follows:
import('Action.McorpworkerAction', APP_PATH . 'Modules/base');//Load the base module yourself action
import('Model.CorpworkerModel', APP_PATH . 'Modules/base');
//Load the model of the base module yourself, otherwise the automatic verification and other methods in the model will fail
$Mworker = new McorpworkerAction(); Instantiate action, be sure to write it in full
$worker["loginname"] =$_REQUEST['loginname'];
$worker["realname"] =$_REQUEST['realname'];
$worker["pass"] =mmin($_REQUEST['pass']);
//Add after constructing data
$r = $Mworker->addfun($worker);
//In this way, the base module's Mcorpworker's addition, deletion, modification and query can be called smoothly! !

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/917035.htmlTechArticleNotes on the use of independent groups of ThinkPHP, thinkphp grouping This article describes the precautions on the use of independent groups of ThinkPHP. Share it with everyone for your reference. The details are as follows: About T...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn