Welcome Guest, Not a member yet? Register   Sign In
Problem loading / using custom database from model

I'm trying to load and use an oracle database within a specific model, but I'm getting errors.

class Model_peopledata extends CI_Model {

public $DB2;

    function __construct()
    $this->$DB2 = $this->load->database("myoracle", TRUE);

    function get_all_rows()
        $query = $this->$DB2->get('MYTABLEORVIEW');
        return $query;


What's wrong? I'm getting: Fatal error: Cannot access empty property in...

How should I load and use this custom database config within a model? And how should I unload this database or close the connection? Is this done automatically?

PD: Tried loading the oracle database from a controller, and works fine.


Theme © iAndrew 2016 - Forum software by © MyBB