thinkphp considerations _php Instances for separate groupings

Source: Internet
Author: User

The examples in this article describe the considerations for using thinkphp separate groupings. Share to everyone for your reference. Specifically as follows:

About thinkphp 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 instructions:

1. Directory structure of separate groupings

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

Note: The separate group action is placed directly under the action directory, and no Lib directory is required (this slight difference pits me one day)

2. Mutual invocation between independent groupings

If you set up an independent group that specializes in data deletion, change and check, other grouping methods call this group of additions and deletions to check the method, you will find many miracles, such as a variety of non-existent hints, model validation inexplicable failure and so on, which is due to a reason: not automatically load the corresponding module!!

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

Copy Code code as follows:
Import (' Action.mcorpworkeraction ', App_path. ' Modules/base ');//Load the action of the Base module yourself
Import (' Model.corpworkermodel ', App_path. ' Modules/base ');
You load the base module model, or automatic verification and so on model method will fail
$Mworker = new Mcorpworkeraction (); Instantiate action, pay attention to write it all
$worker ["LoginName"] =$_request[' loginname '];
$worker ["Realname"] =$_request[' realname '];
$worker ["Pass"] =mmin ($_request[' Pass ']);
Add after constructing data
$r = $Mworker->addfun ($worker);
In order to successfully invoke the base module of the Mcorpworker to check and delete!!

I hope this article will be helpful to everyone's thinkphp framework program design.

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.