![]() |
Undefined property: Database::$db in model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Undefined property: Database::$db in model (/showthread.php?tid=64634) |
Undefined property: Database::$db in model - lcwakeman - 03-15-2016 And now for my next issue. First, I would like to point out that this (before updating) has been working on CI 2. I am getting the above error executing a query builder query in a model. Controller code: Code: <?php Code: <?php and the result: Quote:schema_version I looked at core/model.php and it isn't extending any thing so other than the attributes and methods I define in the model, it is empty and there is now db object. ![]() RE: Undefined property: Database::$db in model - Narf - 03-15-2016 This means you haven't loaded the database class, which happens either via a $this->load->database() class or via the config/autoload.php file. RE: Undefined property: Database::$db in model - lcwakeman - 03-15-2016 It has been a while since I started a new instance. Thanks but it would be nice if that were mentioned in the documentation on models. I think the autoload of the database object was the default in CI 2.0 but that was years ago. RE: Undefined property: Database::$db in model - Narf - 03-15-2016 (03-15-2016, 12:51 PM)lcwakeman Wrote: It has been a while since I started a new instance. Thanks but it would be nice if that were mentioned in the documentation on models. I think the autoload of the database object was the default in CI 2.0 but that was years ago. ... it has always worked like that and it is properly documented. |