Q:

Connect another database in library in Codeigniter

I use two databases, oracle and postgresql. Postgre database is on default and I want to connect oracle where it is needed only. So how can I do this?
Now I want to connect oracle database in my library.
My Code in Library:
     function find_all_subjects($id1,$id2)
{
    $DB1 = $this->load->database('database2', TRUE);
    $sql="sql here";
    $query=$DB1->query($sql);
    return  $query->result();

}

But its giving error below:
Severity: Notice

 Message: Undefined property: Somefunction::$load

Do anyone what's wrong with the code or how to connect another database??

A:

Something like this (Not Tested):
class Classname {

    protected $CI;

    protected $database2;

    public function __construct () {
        $this->CI =& get_instance();
        $this->database2 = $this->CI->load->database('database2', TRUE);
    }

    public function function_name () {
        $this->database2->query('...');
    }

}

