Loading DB Class in Helpers - 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: Loading DB Class in Helpers (/showthread.php?tid=6000) |
Loading DB Class in Helpers - El Forum - 02-11-2008 [eluser]pmonty[/eluser] I am sure this is as obvious as the nose on my face, but how do I implement loading the DB class in a helper function? Paul Loading DB Class in Helpers - El Forum - 02-11-2008 [eluser]Référencement Google[/eluser] $CI =& get_instance(); $CI->load->model('your_model'); Loading DB Class in Helpers - El Forum - 02-11-2008 [eluser]tonanbarbarian[/eluser] Utilizing CodeIgniter Resources within Your Library works for helpers and plugins as well Loading DB Class in Helpers - El Forum - 02-11-2008 [eluser]pmonty[/eluser] Thanks, all. That is exactly what I was looking for. Paul Loading DB Class in Helpers - El Forum - 02-12-2008 [eluser]pmonty[/eluser] Well, trying to implement this, I am still having some problems. Here is my code. Code: CI =& get_instance(); Can anyone see why this returns the PHP Error Quote:An Error Was Encountered Paul Loading DB Class in Helpers - El Forum - 02-12-2008 [eluser]xwero[/eluser] no dollar sign on the first line Loading DB Class in Helpers - El Forum - 02-12-2008 [eluser]pmonty[/eluser] Just a typo in the post. It is there in my code but generating the error as noted. Corrected and as in my helper code: Code: $CI =& get_instance(); Paul Loading DB Class in Helpers - El Forum - 02-12-2008 [eluser]xwero[/eluser] The database class isn't loaded as a library, it has its own load method Code: $CI->load->database(); // loads default group I think you mixed up a few things in your snippet Loading DB Class in Helpers - El Forum - 02-12-2008 [eluser]pmonty[/eluser] Yup, Thanks Xwero. I was confusing sample language from the docs with how to actually implement the call. Your examples did it. Thanks again. paul |