ThinkPHP独立分组使用的注意事项,thinkphp分组
本文实例讲述了ThinkPHP独立分组使用的注意事项。分享给大家供大家参考。具体如下:
关于ThinkPHP的独立分组,功能看上去挺好的,可是官方并没有给出详细的例子和说明,在此,根据实际的开发过程,给予各位php开发人员以下几点说明:
1.独立分组的目录结构
和官方说明一样,建立Modules文件夹,配置config.
注意:独立分组的action直接放在action目录下,不需要lib目录(这点细微的差别坑了我一天)
2.独立分组之间的相互调用
如果你建立了一个独立分组专门处理数据的增删改查,其他分组的方法调用这个分组的增删改查方法时候,你会发现许多奇迹,比如各种不存在的提示,模型验证莫名其妙的失效等等,这都归结于一个原因:没有自动加载相应模块!!
所以,放弃官方的A方法吧,自己加载所有的模块,例如:
复制代码 代码如下:
import('Action.McorpworkerAction', APP_PATH . 'Modules/base');//自己加载base模块的action
import('Model.CorpworkerModel', APP_PATH . 'Modules/base');
//自己加载base模块的model,不然自动验证等等model中的方法会失效
$Mworker = new McorpworkerAction();实例化action,注意要写全啊
$worker["loginname"] =$_REQUEST['loginname'];
$worker["realname"] =$_REQUEST['realname'];
$worker["pass"] =mmin($_REQUEST['pass']);
//构造数据后添加
$r = $Mworker->addfun($worker);
//这样才能顺利调用base模块的 Mcorpworker的增删改查!!
希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool