dqwd71332 2014-12-14 20:17
浏览 55
已采纳

codeigniter $这不要加载到控制器中

i have a problem im trying to deal with for a long time,

i have a codeigniter webapp that im building and i have a problem with the $this of codeigniter

i will show you with so examples:

this is in my controller

$this->site_model->blog_post('title');

this one work perfectly /\

if im loading an other / different model it will load it all good, but if im calling a function in the new model like this:

$this->Admin_model->blog_post('title');

it will give me this

Undefined property: Idx::$Admin_model

Call to a member function get_categories() on a non-object in   

C:\dev\wamp\www\francebeautycoil\application\controllers\idx.php on line 22

if im doing the next code

public $ci = '';

$this->ci =& get_instance(); 

$this->load->model('Admin_model');

$this->ci->Admin_model->blog_post('title');

it will work.

ive tryed all the catital lettes, lowercase letters.

the thing is that its append not only on this model but on few libraries too.

please help, im stuck.

  • 写回答

1条回答 默认 最新

  • dongxiang5879 2014-12-14 20:21
    关注

    Every time you use an model you need to load it first , on second snipped you need to load Admin_model first

    if im loading an other / different model 
    

    On second snppiet you are calling a method on Admin_model not loading it on line below

    $this->Admin_model->blog_post('title');
    

    so load it first

    $this->load->model('Admin_model');
    

    so it becomes

    $this->load->model('Admin_model');
    $this->Admin_model->blog_post('title');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答