Why is it not HomeModel to call CommonModel when thinkPHP uses the D method? Function called externally: {code ...} two types of files: {code ...} {code ...} why is the call of Common/Model instead of Home/Model when thinkPHP uses the D method?
Externally called functions:
namespace Home\Controller;use Think\Controller;public function model_D(){ $stmt=D('shop'); $stmt->say();}
Two types of files:
This is called: C: \ AppServ \ www \ yb1 \ yangbins \ Common \ Model \ shopModel. class. php
()';}}
Why not? C: \ AppServ \ www \ yb1 \ yangbins \ Home \ Model \ shopModel. class. php
';}}
Reply content:
Why is the call of Common/Model instead of Home/Model when thinkPHP uses the D method?
Externally called functions:
namespace Home\Controller;use Think\Controller;public function model_D(){ $stmt=D('shop'); $stmt->say();}
Two types of files:
This is called: C: \ AppServ \ www \ yb1 \ yangbins \ Common \ Model \ shopModel. class. php
()';}}
Why not? C: \ AppServ \ www \ yb1 \ yangbins \ Home \ Model \ shopModel. class. php
';}}
Using the D method, class is not found according to the path specified by the namespace.
The D method loads the first Class to be found according to the priority, and the sequence starts from comon.
There are two ways to solve your problem.
$model = D("Home/Shop");
Use command space
use Home\Model\shopModel;$model = new shopModel();
External call should not be specifieduse Home\Model\shop?