I have a project in which i have to connect with user specified database. I want to implement it in a proper codeigniter\'s style but i dont know how can i do that codeignit
According to the guide, you can manually pass database connectivity settings via the third parameter of $this->load->model
:
$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$this->load->model('Model_name', '', $config);
// or as gorelative notes, to access multiple databases:
$DB2 = $this->load->database($config, TRUE);