I think that can't manage to connect to the database and I don't know why.
I have looked over stackoverflow and found this questions: here and it is not helping me in solving my problem.
I have read the documentation from Codeigniter 3: here and used the option Manually Connecting.
My class from my application controller looks like so:
class home extends CI_Controller {
/**
* Class constructor
* Load database lib
*/
public function __construct()
{
$this->load->database();
}
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/home.php/welcome
* - or -
* http://example.com/home.php/welcome/index
*/
public function index()
{
$query = $this->db->get('users');
foreach ($query->result() as $row)
{
var_dump($row->fullName); //testing purpose
}
//$this->load->view('home', $data);
}
The database config from my application looks like so:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'user',
'password' => 'password',
'database' => 'tasks',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => FALSE
);
And when I access http://localhost/home.php/welcome
I get this error:
Fatal error: Call to a member function database() on null in \www\task\application\controllers\home.php on line 12
I tried var_dump($this->load) and it is a null and from here my assumption that it can't establish a connection to the database.