index_model.php is below:
<?php
class index_model extends CI_Model {
function __construct() {
parent::__construct();
}
function getVideo()
{
$query = $this->db->get('videolar');
return $query->result_array();
}
}
?>
And index controller is below, too
<?php
class index extends CI_Controller {
function __construct() {
parent::__construct();
}
function index()
{
$this->load->model('index_model');
$data['video'] = $this->index_model->getVideo();
$this->load->view('index',$data);
}
}
?>
When I call index controller it returns this error
Fatal error: Call to a member function get() on a non-object in
/var/www/atlet/application/models/index_model.php on line 10
I set database in autoload.php.
$autoload[‘packages’] = array(‘database’);
You need to load the database in the
librariesarray, not thepackagesarray: