douke1954 2015-11-24 06:12
浏览 46
已采纳

Codeigniter模型加载错误

I had a working project uploaded to server 2 week before. It was working fine until now. Below is code for model awsmodel.php

class Awsmodel extends MY_Model {

    function __construct()
    {

    }
    // some other functions
}

MY_Model again extends to CI_model.

class MY_Model extends CI_Model {
// required functions
}

From controller pages.php I am calling the function like below.

class Pages extends MY_Controller {
  public function index()
    {
        $data = $this->allCommonMenu();
        $this->load->model('Awsmodel');
        $data['featured'] = $this->Awsmodel->featuredProp();
        $this->load->view('home_pz',$data);
    }
 }

The above code suddenly stooped working today. After some test and tries, I got to know that when I comment below 2 lines from controller function then The page loads.

  $this->load->model('Awsmodel');
  $data['featured'] = $this->Awsmodel->featuredProp();

I have changed environment variable to 'development' and tested but still no error message shows. In firefox its showing a blank page, where as in chrome it shows 500 server error. The same code was working since 2 weeks. Don't know why its not working now. If anyone can help me out ?
I am using CI version 2.1.4

  • 写回答

1条回答 默认 最新

  • dousha2020 2015-11-24 06:35
    关注

    If you using CI 3.0 please load model like this

    class Pages extends MY_Controller {
      public function index()
        {
            $data = $this->allCommonMenu();
            $this->load->model('awsmodel'); //as your model filename: awsmodel.php
            $data['featured'] = $this->Awsmodel->featuredProp();
            //$data['featured'] = $this->awsmodel->featuredProp();// for  CI version 2.1.4 –
            $this->load->view('home_pz',$data);
        }
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料