i have controller to show database record on table
function gkategorimaterial()
{
$this->load->model('m_kategorimaterial');
$data['kirim'] = $this->m_kategorimaterial->read(); //error pointing on this line
$data['title'] = 'QB Ambil Kategori Material / Jasa';
$this->load->view('head',$data);
$this->load->view('g/gkategorimaterial',$data);
}
that gkategorimaterial()
was adapted from
function vkategorimaterial()
{
$this->load->model('m_kategorimaterial');
$data['kirim'] = $this->m_kategorimaterial->read();
$data['title'] = 'QB Kategori Material';
$this->load->view('head',$data);
$this->load->view('v/vkategorimaterial',$data);
}
which has the some function, to show the table, the vkategorimaterial()
success to retrieve the record.
here is the model of `m_kategorimaterial
function read()
{
$query = $this->db->order_by('Kode_Kategori_Material_Jasa','DESC');
$query = $this->db->get('ms_kategori_material');
if($query->num_rows()>0)
{
return $query->result();
}
else
{
return null;
}
}
A PHP Error was encountered
Severity: Notice
Message: Undefined property: C_materialjasa::$m_kategorimaterial
Filename: controllers/c_materialjasa.php
Line Number: 140
i believe it has nothing to do with the models, but i don't know what the error is, since i just copy paste the first controller which is vkategorimaterial()
controller, and rename the variable
Are database loaded on m_kategorimaterial?
$this->load->database();
or set in ./application/config/autoload.php
$autoload['libraries'] = array('database');
Or try add parent in controller:
function __construct()
{
parent::__construct();
}
Loading a model:
Controller:
$this->load->model('Model_name');
Model ('models/Model_name.php')
class Model_name extends CI_Model {
function __construct()
{
parent::__construct();
}
function read() { return; }
}
Make sure that is model file CHMOD-ed to 0755!
my bad ! i wrote class classname
extends CI_Controller on the model file