Here is some code excerpted from Codeigniter’s user guide about models. There’s no explicit load of the databass class, in which the object db, method get in the code below have to be defined. I’ve checked the autoload file, there is no autoload of this specific class.
class Blogmodel extends CI_Model {
var $title = '';
var $content = '';
var $date = '';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_last_ten_entries()
{
$query = $this->db->get('entries', 10);
return $query->result();
}
function insert_entry()
{
$this->title = $_POST['title']; // please read the below note
$this->content = $_POST['content'];
$this->date = time();
$this->db->insert('entries', $this);
}
function update_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['content'];
$this->date = time();
$this->db->update('entries', $this, array('id' => $_POST['id']));
}
}
The CodeIgniter documentation states two methods of loading the database library and connection:
Database – User Guide
Also, when loading the model as referenced by jss: