[eluser]DougW[/eluser]
I need my CI app to access two different databases. I do this by defining the second one in config and then in the models where I want to use it, I do the following:
$this->otherdb = $this->load->database('other', TRUE);
in the constructor for the model.
My problem now is I have a class file (library) that I need to access this second database in. I tried putting the above line int he controller, then doing this:
$CI =& get_instance();
$this->otherdb = & $CI->otherdb;
In the constructor of the class, (of course defining var otherdb=NULL as well) but it doesn't seem to work. I know it kinda goes against the philosophy of models to do database activity in the library, but they are ajax functions and I am trying to keep them together. Is there a way to give access to or load databases in the library classes or is there an easy way to load a model from withing the class? What is the 'best practice' method?