Reputation: 816
Model/blogmodel.php:
class Blogmodel extends CI_Model {
public function get_recent_post($num){
$query = $this->db->get('wdr_blog_post', $num);
return $query->result();
}
}
Controller/blog.php:
class Blog extends CI_Controller {
public function index(){
$this->load->model('blogmodel');
$posts = $this->Blogmodel->get_recent_post(5);
}
}
Error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Blog::$Blogmodel
Filename: controllers/blog.php
Line Number: 7
Fatal error: Call to a member function get_recent_post() on a non-object in G:\server\htdocs\xyz\app\controllers\blog.php on line 7
Upvotes: 0
Views: 68
Reputation: 30721
Just guessing...
class Blog extends CI_Controller {
public function index(){
$this->Blogmodel = $this->load->model('blogmodel');
$posts = $this->Blogmodel->get_recent_post(5);
}
}
Upvotes: 1