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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?