CodeIgniter: unable to load database from model
I wrote a new model for my CodeIgniter framework. I am trying to load the database from a constructor function, but I am getting the following error:
Severity: Notice
Message: Undefined property: userdb::$load
Filename: models/userdb.php
Line Number: 7
Fatal error: Call to a member function database() on a non-object in
/var/www/abc/system/application/models/userdb.php on line 7
Here is my model:
<?php
class userdb extends Model {
function __construct() {
$this->load->database();
}
?>
What am I doing wrong here?
+2
a source to share
2 answers
I'm not sure if this will cause a problem or not, but model names are assumed to have the first letter. http://ellislab.com/codeigniter/user-guide/general/models.html Jens is also right that you need to call the parent constructor as well.
+3
a source to share