Home >Backend Development >PHP Tutorial >thinkphp3.2.0版本 D方法调用自定义模型类显示找不到该类,Class 'HomeModelUserModel' not found

thinkphp3.2.0版本 D方法调用自定义模型类显示找不到该类,Class 'HomeModelUserModel' not found

WBOY
WBOYOriginal
2016-06-23 13:37:321430browse

如上,控制器UserController.class.php

namespace Home\Controller;
use Think\Controller;
use Home\Model\UserModel;

class UserController extends Controller {
    public function index(){
        $user = D('User')->login();
        print_r($user);
    }
}

自定义模型类:UserModel.class.php

namespace Home\Model;
use Think\Model;

class UserModel extends Model {
   public function login(){
echo "1234";
   } 
}

刚才说错了 是提示:ERR: Think\Model:login方法不存在!他怎么没有调用自定义模型类呢


回复讨论(解决方案)

问题解决 用大D(‘’user‘);报错表不存在,打开config把表前缀注释掉直接报UserModel.class.php里面出错,处理后把表前缀打开运行就OK了  里面的细节让我还是很晕 希望各位大神帮我解决为什么不直接报错呢?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn