Reputation: 35
I am new to BF. I am learning BF by following the tutorial here, but I cant figure out why it keep prompt me error message as below:
Fatal error: Call to a member function where() on a non-object in ...
Here is the code:
class Content extends Admin_Controller {
public function __construct(){
parent::__construct();
Template::set('toolbar_title', 'Manage Your Blog');
}
public function index(){
$posts = $this->post_model->where('deleted', 0)->find_all();
Template::set('posts', $posts);
Template::render();
}
}
Can someone guide me on this? Thanks
Upvotes: 0
Views: 582
Reputation: 493
bborisovs is right, you need to load the model in the constructor, before you can use the obgject:
$this->load->model('post_model', null, true);
Also make sure your model exists.
Upvotes: 1