尝试从 codeigniter 帮助程序文件访问用户类对象时,它抛出类似 Class 'User' not found
的错误。我的代码是这样的
$u = new User();
$u->get();
我可以在库文件中使用它,但不能在帮助程序文件中使用它。有人可以帮助我吗?
最佳答案
为了在助手中使用模型,您必须:
// Get a reference to the controller object
$CI = get_instance();
// You may need to load the model if it hasn't been pre-loaded
$CI->load->model('User');
// Call a function of the model
$CI->User->get();
希望对你有帮助!
关于php - 使用 wanwizard datamapper 时调用 codeginiter 帮助程序文件中的模型类对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15757638/