[eluser]yapaarachchi[/eluser]
Hello,
I got following error when I am going to use
$this->load->database();. I use
Eclipse as my IDE.
Fatal error: Call to a member function database() on a non-object in C:\xampp\htdocs\TestCI\application\models\news_model.php on line 7
And this is my code(../models/news_model.php)
Code:
class News_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
public function get_news($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get('news');
return $query->result_array();
}
$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}
}
And also I put following code in to autoload.php
Code:
$autoload['libraries'] = array('database');
Can anyone tell how to solve this???