How to access CodeIgniter user defined models?

后端 未结 2 855
没有蜡笔的小新
没有蜡笔的小新 2021-01-27 04:38

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_wher

相关标签:
2条回答
  • 2021-01-27 04:39

    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'");

    0 讨论(0)
  • 2021-01-27 05:02

    You could try to instantiate your model object like:

    include_once('path/modelname.php');
    $home_model = new Home_model();
    $home_model->set_where(....);
    

    make sure your model extends de default CI model class.

    You could also use $CI->load->model(modelname); instead of include... It's easier to deal with path problems, however it would be a little less efficient because load->model will instantiate an object.

    0 讨论(0)
提交回复
热议问题