Welcome Guest, Not a member yet? Register   Sign In
Extending Controller
#1

[eluser]Kemik[/eluser]
Hello,

If I extend the controller, e.g. class Public_Controller extends Controller and then class User_Controller extends Public_Controller.

E.g.
Code:
class Public_Controller extends Controller {

    function Public_Controller() {
        parent::Controller();
        
        $row = 1
        // retrieve all descendants of $root node
        $data['query0'] = $this->controller_model->get_descendants($row);
        
        $this->load->vars($data);
    }
}
class User_Controller extends Public_Controller {

    function User_Controller() {
        parent::Controller();
        
        if (!logged_in()) {
            redirect('user/login');
            return;
        }
    }
}

Will I be able to use $query0 from the Public_Controller in a controller whos parent is User_Controller? I've tried it atm but it just says Fatal error: Call to a member function on a non-object on the line that calls $query0.

Is there a way to fix this or do I need to put the query in each extension?


Messages In This Thread
Extending Controller - by El Forum - 03-21-2008, 05:28 PM
Extending Controller - by El Forum - 03-21-2008, 06:04 PM
Extending Controller - by El Forum - 03-21-2008, 09:19 PM
Extending Controller - by El Forum - 03-21-2008, 09:41 PM
Extending Controller - by El Forum - 03-31-2009, 03:01 AM
Extending Controller - by El Forum - 03-31-2009, 08:56 AM
Extending Controller - by El Forum - 05-24-2009, 06:35 AM
Extending Controller - by El Forum - 05-24-2009, 07:22 AM
Extending Controller - by El Forum - 05-24-2009, 07:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB