Welcome Guest, Not a member yet? Register   Sign In
Clarification on database access in helpers, models and plugins
#2

[eluser]gon[/eluser]
Hi,

You can access DB or any other CodeIgniter resource by getting a reference to the CI object:
$CI =& get_instance();
This object works the same way as the controllers. So, instead of $this->load->library(... you can do $CI->load->library(...
$CI->db is a reference to the DB object.
This way you can access DB from libraries, helpers or wherever you need.


Anyway I find your system a little overbloated, even if I don't understand it fully.
For searches I usually have a Search library. You should pass URL parameters to that library, and get search results. The library should convert names to ids, perform the searches, possibly using models for that, and return a nicely formatted array or object, ready to be passed to the views.


Messages In This Thread
Clarification on database access in helpers, models and plugins - by El Forum - 09-29-2009, 02:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB