[eluser]fdgsuhofdshjdfgh[/eluser]
Hi,
I have 2 database configs defined in config/database.php:
Code:
$active_group = 'primary';
$active_record = TRUE;
$db['primary']['hostname'] = 'localhost';
...
$db['secondary']['hostname'] = 'localhost';
...
I have primary set to my default. I have a model that needs to use the secondary database so I do the following, as instructed by the documentation:
Code:
function list_clients($company)
{
$this->load->database('secondary');
$company_query = $this->db->query('SELECT * FROM secondary_table');
}
but this doesn't work, it tries to connect to the primary database.
I have tested if it's a configuration error by switching the active_group variable to "secondary" and then it connects fine and works as expected. So the problem is for some reason:
Code:
$this->load->database('secondary');
is being ignored. What am I doing wrong? Any gotcha I'm missing? Tried on both Windows and Linux. PHP 5.3.4