尝试从codeigniter帮助文件访问用户类对象时,其抛出错误如Class 'User' not found
。我的代码是这样的
$u = new User();
$u->get();
我可以在库文件中使用它,但不能在辅助文件中使用它。有人可以帮助我。
答案 0 :(得分:1)
为了在助手中使用模型,你必须:
// 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();
希望它会有所帮助!