如何访问CodeIgniter用户定义的模型? [英] How to access CodeIgniter user defined models?
问题描述
当我想在自定义用户定义库中的CodeIgniter中访问用户定义模型的函数时,它会抛出
在非对象上的成员函数Set_where()
虽然我通过使用这个库内部加载模型
$ CI =& get_instance();
$ CI-> load-> model('home_model');
我使用这个代码访问 home_model
class
$ CI-> home_model-> Set_where(film_feature ='Y');
现在它会抛出上面的错误。
那么有人可以帮我解决这个错误吗?
我的工作代码现在是..
$ CI =& get_instance();
$ CI-> load-> model('home_model');
$ CI - > home_model-> Set_where(film_feature ='Y');
When I want to access a function of a user defined model in CodeIgniter inside a custom user defined library it throws
Call to a member function Set_where() on a non-object
Although I load the model by using this inside that library
$CI =& get_instance();
$CI->load->model('home_model');
And I'm using this code to access the function inside home_model
class
$CI->home_model->Set_where("film_feature='Y'");
So now it throws the above error.
So could someone please help me solve this error?
Now i fix the issue just adding $CI =& get_instance(); into that function where i want to fetch previously i declare that $CI =& get_instance(); in another function of that class for which it was not instantiated.
My working code is now..
$CI =& get_instance();
$CI->load->model('home_model');
$CI->home_model->Set_where("film_feature='Y'");
这篇关于如何访问CodeIgniter用户定义的模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!