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

(This post was last modified: 04-17-2017, 02:40 PM by marksman.)

I found no problem with your structure, unless you where missing the case of your files. It is because your model class is in Studly_Snake case and if your file is not studly_snake.php then you may encounter problems for some reasons, I'm not sure why but I'ved encounter those from the past. If your problem persist just to make sure you were inheriting the right object, try to store your object in global variable where it can be inherited by your class and it's child.

PHP Code:
Class Backend_Controller extends MY_Controller
{
 
   protected $oAuthModel;
 
   
    public 
function __construct()
 
  {
 
      parent::__construct();
 
      $this->load->model('Auth_Model');
 
      $this->oAuthModel $this->Auth_Model;
 
      unset($this->Auth_Model);
 
  }


PHP Code:
Class Dashboard extends Backend_Controller
{
 
   public function __construct()
 
   {
 
      parent::__construct();
 
   }

 
   public function index()
 
   {
 
      $content $this->oAuthModel->is_logged_in();
 
   }


and I missed it @Diederick is right, your controller might not be loaded properly. It is either you follow MY_Controller convention or change the $config['subclass_prefix'] = 'MY_'; in your config.php plus you may write your own autoload class in MY_Controller convention if you don't want to change your config.
God Bless CI Contributors Smile
Reply


Messages In This Thread
RE: Clarification about MY_Controller and relative inheritances - by marksman - 04-17-2017, 02:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB