如何访问CodeIgniter用户定义的模型? [英] How to access CodeIgniter user defined models?

查看:66
本文介绍了如何访问CodeIgniter用户定义的模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想在自定义用户定义库中的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 =& get_instance();



我的工作代码现在是..



$ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆