gpt4 book ai didi

php - 使用 wanwizard datamapper 时调用 codeginiter 帮助程序文件中的模型类对象

转载 作者:行者123 更新时间:2023-11-29 13:56:37 25 4
gpt4 key购买 nike

尝试从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com