Fatal error: Call to undefined method CI_Model::CI_Model() in D:xampphtdocscodeigniterapplicationcoreMY_Model.php on line 8

又遇到另一個問題了…
我嘗試 extends CI_Model 這一個Class
把一些在model 上 經常用到的 功能放在這裡…
但是又出現了這個問題
Fatal error: Call to undefined method CI_Model::CI_Model()

Fatal error: Call to undefined method CI_Model::CI_Model() in D:xampphtdocscodeigniterapplicationcoreMY_Model.php on line 8

class MY_Model extends CI_Model
{

    function MY_Model()
    {
        parent::CI_Model();
    }

}

之後終於找到了解決方法
只要除去 parent::CI_Model(); 便可

class MY_Model extends CI_Model
{

    function MY_Model()
    {

    }
}

真是要好好學習Codeigniter 才可…
不可以再犯這些錯…

Hope you find it useful.

One thought on “Fatal error: Call to undefined method CI_Model::CI_Model() in D:xampphtdocscodeigniterapplicationcoreMY_Model.php on line 8

  1. santosh

    parent::Controller();

    //use this line instead of

    function Home()
    {
    parent::__construct();
    }

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.