0

私はcodeIgniterが初めてです。Fatal error: Call to a member function get_posts() on a non-object in C:\xampp\htdocs\ci_series_5\application\controllers\posts.php on line 12 という問題があります

class Posts extends CI_Controller{

    function _construct(){
        parent::_construct();
        $this->load->model('post');

    }

    function index(){
        $data['posts']=$this->post->get_posts();         line 12
        $this->load->view('post_index',$data);
    }

モデルのPost.phpは以下です

class Post extends CI_Model{

    function get_posts($num=20,$start=0){           
        $this->db->select()->from('posts')
        ->where('active',1)->order_by('date_added', 'desc')
        ->limit($num,$start);
        $query=$this->db->get();
        return $query->result_array();
    }

    function get_post($postID){
        $this->db->select()->from('posts')->where(array('active'=>1,
        'postID'=>$postID))->order_by('date_added','desc');
        $query=$this->db->get();
        return $query->first_row('array');
    }
4

2 に答える 2