• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.