I wanted to make a webapplication using codeigniter but it is a while since I've used it and I'm getting an error whenever I try to load a model in my controller. I'm probably doing something stupid wrong but I can't figure out what it is. So please help me out if u can.
This is the error I get:
Here is the code of my model:
<?php
class post_model extends CI_Model {
function __construct() {
parent::__construct();
}
function getAllPosts() {
$this->db->order_by('date', 'desc');
$query = $this->db->get('post');
return $query->result();
}
}
?>
Here is the code of my controller where I load the model:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Post extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('post_model');
}
public function index() {
$data['title'] = 'Berichten';
$data['posts'] = $this->post_model->getAllPosts();
$this->template->load('posts', $data);
}
}
Autoload:
$autoload['helper'] = array('url', 'form', 'date');
$autoload['model'] = array();
Solved: I couldn't solve it but I made a new project and copy-pasted my code and now it works just fine, so no idea what was wrong.