I am a newbie with codeigniter and trying to learn crud in codeigniter..
My site controller is :
class Site extends CI_Controller
{
function index()
{
$data = array();
if($query = $this->site_model->get_records())
{
$data['records'] = $query;
}
$this->load->view('options_view', $data);
}
And my site_model is :
class Site_model extends CI_Model {
function __construct(){
parent::__construct();
}
function get_records()
{
$query = $this->db->get('data');
return $query->result();
}
function add_record($data)
{
$this->db->insert('data', $data);
return;
}
function update_record($data)
{
$this->db->where('id', 12);
$this->db->update('data', $data);
}
function delete_row()
{
$this->db->where('id', $this->uri->segment(3));
$this->db->delete('data');
}
}
I made $autoload[‘libraries’] = array(‘database’);
When i try to check the site I get error :
Severity: Notice
Message: Undefined property: Site::$site_model
Filename: controllers/site.php
Line Number: 9
What is wrong with this code?
Load the model: