• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switching database config for model not working: $this->load->database('name')


I have 2 database configs defined in config/database.php:

$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:

function list_clients($company)
    $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:


is being ignored. What am I doing wrong? Any gotcha I'm missing? Tried on both Windows and Linux. PHP 5.3.4

Messages In This Thread
Switching database config for model not working: $this->load->database('name') - by El Forum - 07-21-2011, 10:11 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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