CodeIgniter Forums
Model error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Model error (/thread-18975.html)



Model error - El Forum - 05-24-2009

[eluser]barak[/eluser]
Hi,
I have a problem loading a model.
This is how its start:

Code:
function show()
    {
        parent::Model();
        $query = $this->db->query(" SELECT *FROM `army`  WHERE `id` = '1' ")or die("error reading id");

The error is on the query line.
This is the error:
Code:
Fatal error: Call to a member function query() on a non-object in C:\wamp\www\arena\system\application\models\s_train.php on line 12

Last time I had this error because I forget to parent the function.
But now I do have this line.

Thank you.


Model error - El Forum - 05-24-2009

[eluser]umefarooq[/eluser]
hi are you calling database library if not you can load it in you controller or either in config/autoload file,

Code:
$this->load->library('database');



Model error - El Forum - 05-24-2009

[eluser]Dam1an[/eluser]
Actually, you don't load the database library like other libraries, see user guide for more info


Model error - El Forum - 05-24-2009

[eluser]TheFuzzy0ne[/eluser]
It should be $this->load->database(), but I think it goes through the library loader anyway, so that should work.


Model error - El Forum - 05-24-2009

[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1243191583"]It should be $this->load->database, but I think it goes through the library loader anyway, so that should work.[/quote]

I knoq the db is autoloaded with the rest of the libraries, but I remember someone having a prpoblem trying to load it manually via the normal librray loader (also, its good for them to reads the docs Tongue)