Notes for using ThinkPHP independent grouping

Source: Internet
Author: User
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:

  1. Import ('action. mcorpworkeraction', APP_PATH. 'Les les/base'); // load the Action of the base module by yourself
  2. Import ('Model. CorpworkerModel ', APP_PATH. 'Les les/base ');
  3. // Load the model of the base module by yourself. Otherwise, the methods in the model such as automatic verification will become invalid.
  4. $ Mworker = new McorpworkerAction (); instantiate the action. Be sure to write it fully.
  5. $ Worker ["loginname"] = $ _ REQUEST ['loginname'];
  6. $ Worker ["realname"] = $ _ REQUEST ['realname'];
  7. $ Worker ["pass"] = mmin ($ _ REQUEST ['pass']);
  8. // Construct the data and add it
  9. $ R = $ Mworker-> addfun ($ worker );
  10. // In this way, you can call the addition, deletion, modification, and query of the Mcorpworker of the base module !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.