The Class of the custom model Class called by the method D in thinkphp3.2.0 cannot be found. The Class 'homemodelusermodel' notfound

Source: Internet
Author: User
Thinkphp3.2.0 version D method call custom model class display cannot find this class, ClassHomeModelUserModelnotfound as above, controller 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 );
}
}

Custom model class: UserModel. class. php

Namespace Home \ Model;
Use Think \ Model;

Class UserModel extends Model {
Public function login (){
Echo & quot; 1234 & quot ";
}
}

The error message "ERR: Think \ Model: login" does not exist! Why didn't he call the custom model class?


Reply to discussion (solution)

To solve the problem, use big D ('user'). If the error table does not exist, open config and comment out the table prefix and report UserModel directly. class. an error occurs in php. after processing the table prefix, it is okay to run the table prefix. I am still dizzy. hope you guys can help me solve the problem. why don't I directly report an error?

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.