[eluser]WanWizard[/eluser]
You can load the database (this way) only once, after which it is assigned to $this->db. If you try to load another one, it detects it's already loaded, and returns false.
Secondly, if you try to load a database with a manual config, you need to pass all information in the array. If you want to reuse the default config, you have to load that first.
Try
Code:
// load the database config
include(APPPATH.'config/database'.EXT);
// get the default config
$config = $db['default'];
// override the database name
$config['database'] = "study_".$this->studycode;
// do not auto initialize the connection
$config['autoinit'] = FALSE;
// load the database driver
$db = $this->load->database($config, TRUE);
// and see if we can initialize it
if ( $db->initialize() ) {
echo "true";
}
else
{
echo "false";
}