Welcome Guest, Not a member yet? Register   Sign In
Clarification about MY_Controller and relative inheritances
#2

What is the exact error you get?

I see nothing wrong with your understanding of inheritance. I don't see anything wrong with your code either. I constructed a test case doing the same as you (as I understand it) the test works just fine.

File: application/core/MY_Controller.php

PHP Code:
class MY_Controller extends CI_Controller
{
 function 
__construct()
 {
 
parent::__construct();
 }
}

class 
Backend extends MY_Controller
{

 
   public function __construct()
 
   {
 
       parent::__construct();
 
       $this->load->model('rivers_m');
 
   }



The model is one I had handy that is known to work.

File: application/controllers/Welcome.php

PHP Code:
class Welcome extends Backend
{
 
   function __construct()
 
   {
 
       parent::__construct();
 
   }

 
   public function index()
 
   {
 
       $data $this->rivers_m->getRivers();
 
       var_dump($data);
 
   

The var_dump produces the expected output.
Reply


Messages In This Thread
RE: Clarification about MY_Controller and relative inheritances - by dave friend - 04-17-2017, 12:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB