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 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器