Welcome Guest, Not a member yet? Register   Sign In
dbforge accessing private variables
#1

[eluser]Unknown[/eluser]
I've noticed that Loader.php directly tries to access $CI->db within the dbforge function, when I run $this->load->dbforge():

function dbforge()
{
if ( ! class_exists('CI_DB'))
{
$this->database();
}

$CI =& get_instance();
require_once(BASEPATH.'database/DB_forge'.EXT);
require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
$class = 'CI_DB_'.$CI->db->dbdriver.'_forge';

$CI->dbforge = new $class();
}

So this won't work for me unless I declare public $db; within my constructor (which extends CI_CONTROLLER). The problem happens with the last require statement above. If I declare it as private, Loader.php can't see it. Furthermore, what if I have a second connection to a different database, then CI is just using hard coding to assume I want to use 'db' and not any other name I may have given the db variable.




Theme © iAndrew 2016 - Forum software by © MyBB