Welcome Guest, Not a member yet? Register   Sign In
Undefined property: Admin::$db when I put database on autoload

I'm getting this error when trying to interact with the database with ORM.
Undefined property: Admin::$db

Stack Overflow says I should put database inside the libraries section of autoload.php

I have already done this and I still get the error. It reads 

$autoload['libraries'] = array('database');

Please help.

I might be stating the obvious here but did you add the database credentials to config/database.php ?
I use the above method all the time and never had any issues.

Can you give us any other infos on this?
On the package it said needs Windows 7 or better. So I installed Linux.

(This post was last modified: 06-26-2017, 03:43 AM by desbest.)

Yes I did to that yes.

It lets me access the database in the index() method for AdminController but not in the __construct() method in the AdminController

Why would it let me access the database in one method but not other, if I have database autoload on?

I'm using Windows 8.1


class Admin extends CI_Controller {

public function __construct()
The above code does not work. I get Undefined property: Admin::$load error.

When using a constructor you must first call the parent constuctor of CI_Controller

PHP Code:
public function __construct()


Theme © iAndrew 2016 - Forum software by © MyBB