thinkphp considerations for using independent groupings _php instances

Source: Internet
Author: User
The examples in this article describe the considerations for using thinkphp independent groupings. Share to everyone for your reference. Specific as follows:

About Thinkphp's independent grouping, the function looks very good, but the official does not give the detailed example and the explanation, here, according to the actual development process, gives the PHP developer the following several notes:

1. Separate grouping of directory structures

As with the official instructions, create the Modules folder and configure CONFIG.

Note: The standalone group action is placed directly under the action directory and does not require the Lib directory (this slight difference pits my day)

2. Mutual invocation between separate groupings

If you set up a separate group to deal with the deletion of data, and other methods of grouping calls the method of adding and deleting the group, you will find many miracles, such as a variety of non-existent hints, model validation inexplicable failure and so on, which are due to a reason: no automatic loading of the corresponding module!!

So, give up the official a method and load all the modules yourself, for example:
Copy the Code code as follows: Import (' Action.mcorpworkeraction ', App_path. ' Modules/base ');//action to load the base module yourself
Import (' Model.corpworkermodel ', App_path. ' Modules/base ');
Load the model of the base module yourself, or the methods in the model will be invalidated, etc.
$Mworker = new Mcorpworkeraction (); Instantiate action, pay attention to write it all.
$worker ["LoginName"] =$_request[' loginname '];
$worker ["Realname"] =$_request[' realname '];
$worker ["Pass"] =mmin ($_request[' Pass ');
After you construct the data, add
$r = $Mworker->addfun ($worker);
This will be able to successfully call the base module of the Mcorpworker additions and deletions to change!!

It is hoped that this article will be helpful to everyone's thinkphp framework design.

  • Related Article

    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.