title: connect multiple server in single codeigniter application
body: <p>I am trying to connect multiple server connection in 
  application/config/database.php file
  actually I am trying to master slave database in CodeIgniter</p>
  
  <h2>here is my database.php</h2>
  
  <pre><code>$active_group = 'default';
  $active_record = TRUE;
  
  $db['default']['hostname'] = 'localhost';
  $db['default']['username'] = 'xxx';
  $db['default']['password'] = 'xxx';
  $db['default']['database'] = 'xxx';
  $db['default']['dbdriver'] = 'mysql';
  $db['default']['dbprefix'] = '';
  $db['default']['pconnect'] = TRUE;
  $db['default']['db_debug'] = TRUE;
  $db['default']['cache_on'] = FALSE;
  $db['default']['cachedir'] = '';
  $db['default']['char_set'] = 'utf8';
  $db['default']['dbcollat'] = 'utf8_general_ci';
  $db['default']['swap_pre'] = '';
  $db['default']['autoinit'] = TRUE;
  $db['default']['stricton'] = FALSE;
  
  /*
  $active_group = 'anotherdb';
  $active_record = TRUE;*/
  
  $db['anotherdb']['hostname'] = 'xx.xx.xxx.xx';
  $db['anotherdb']['username'] = 'xxuser';
  $db['anotherdb']['password'] = 'xxxx';
  $db['anotherdb']['database'] = 'xxx';
  $db['anotherdb']['dbdriver'] = 'mysql';
  $db['anotherdb']['dbprefix'] = '';
  $db['anotherdb']['pconnect'] = TRUE;
  $db['anotherdb']['db_debug'] = TRUE;
  $db['anotherdb']['cache_on'] = FALSE;
  $db['anotherdb']['cachedir'] = '';
  $db['anotherdb']['char_set'] = 'utf8';
  $db['anotherdb']['dbcollat'] = 'utf8_general_ci';
  $db['anotherdb']['swap_pre'] = '';
  $db['anotherdb']['autoinit'] = TRUE;
  $db['anotherdb']['stricton'] = FALSE;
  </code></pre>
  
  <h2>and here is my controller code</h2>
  
  <pre><code>$a = $this-&gt;load-&gt;database('default', TRUE);
  $b = $this-&gt;load-&gt;database('anotherdb', TRUE);
  echo "&lt;br&gt;".$a-&gt;conn_id;
  echo "&lt;br&gt;".$b-&gt;conn_id;
  </code></pre>
  
  <h1>but error comes as :</h1>
  
  <p>A Database Error Occurred</p>
  
  <p>Unable to connect to your database server using the provided settings.</p>
  
  <p>Filename: core/Loader.php</p>
  
  <p>Line Number: 338</p>