CodeIgniter Forums

Full Version: Problem loading / using custom database from model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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.