Ravi Soni
Ravi Soni

Reputation: 2250

Codeiginter : undefined property class::$load

I am developing a project using codeigniter MVC and facing a weird problem when creating a controller and try loading a model in its constructor

require_once("secure_area.php");
class posstatics extends Secure_area{
    function __construct(){
        $this->load->model('sale'); //at this i am getting the error saying undefined prop
    }
}

The secure_area.php file extends the CI_Controller the same is working on the other section of the app but this class created nuisance for me :(

Upvotes: 0

Views: 1106

Answers (1)

Itai Sagi
Itai Sagi

Reputation: 5615

first of all, you don't need to manually require, codeigniter takes care of that automatically.

assuming that Secure_area extends CI_Controller, you need to call the super method.

class posstatics extends Secure_area{
    function __construct(){
        parent::__construct();
        $this->load->model('sale'); //at this i am getting the error saying undefined prop
    }
}

Upvotes: 5

Related Questions