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

(04-17-2017, 04:34 PM)marksman Wrote: @Dave friend, have you tried to var_dump in Backend_Controller's constructor? I'm afraid its not loaded. or try to instantiate it in your class Dashboard which is basically loaded by magic router.

PHP Code:
class Dashboard extends MY_Controller
{
 
   public function index()
 
   {
 
       // If this returns an error then your Backend_Controller is not loaded
 
       $oBackend = new Backend_Controller();
 
   }


You extend My_Controller to CI_Controller while Backend_Controller extends MY_Controller. I think you missed it my friend. No one extends or instantiate Backend_Controller so no chance to access it's instance, your Dashboard also extends to MY_Controller. In your structure MY_Controller stands as your base class neither Backend_Controller nor Frontend_Controller. That's why.

I think you're reading it wrong. Look at my code again.

  1. MY_Controller extends CI_Controller;
  2. Backend extends MY_Controller;
  3. Welcome extends Backend;
I substituted "Welcome" for the OP's "Dashboard" cause I was too lazy to create another class. Angel

The inheritance chain will instantiate Backend.

I know "Backend" was created because the object "river_m" is successfully used in "Welcome" to return data from the db.

In my example I did not define a Frontend class but if I did it would extend MY_Controller. Smile
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB