![]() |
Error when using db library (set to autoload) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Error when using db library (set to autoload) (/showthread.php?tid=43956) |
Error when using db library (set to autoload) - El Forum - 07-28-2011 [eluser]Ren83[/eluser] Hi, when i try this in a model: $this->db->query('some query'); Im getting this error: Fatal error: Call to a member function query() on a non-object in D:\wamp\www\......... I DID add 'database ' to the $autoload['libraries'] array on autoload.php. What is the problem? Thanks. Error when using db library (set to autoload) - El Forum - 07-28-2011 [eluser]ghprod[/eluser] Hi, where do u load this code? at controller/libraries/models? dont forget to set $ci = get_instance() if you load in libraries or helper ![]() regards Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]Ren83[/eluser] I load it in a model (application/models) Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]ghprod[/eluser] would u mind if you post your model here? regards Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]Ren83[/eluser] Code: <?php Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]ghprod[/eluser] so strange your error occurred only when object "db" wasnt set .. just make sure you already load all required things to run DB object and dont forget set config/database.php regards Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]Ren83[/eluser] I setted config/database.php. anyone have an idea? Error when using db library (set to autoload) - El Forum - 07-29-2011 [eluser]Ren83[/eluser] Here is some more info: This is the default controller from wich i call to Staff controller - Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); And here is the Staff controller wich call to Staff model the i reminded previous post: Code: class Staff extends CI_Controller |