title: Codeigniter - multiple database connections
body: <p>I have to retrieve a MySQL database information from master database and then connect to that database, and fetch some records.</p>
  
  <p>I mean that holding one database I want to load another database.</p>
  
  <p>Is it possible with Codeigniter? Right now I'm using following lines of code in my model.</p>
  
  <pre><code>function connectDb($credential)
  {
  
      $config['hostname'] = $credential['server'];
      $config['username'] = $credential['username'];
      $config['password'] = $credential['password'];
      $config['database'] = $credential['database'];
      $config['dbdriver'] = "mysql";
      $config['dbprefix'] = "";
      $config['pconnect'] = FALSE;
      $config['db_debug'] = TRUE;
      $config['cache_on'] = FALSE;
      $config['cachedir'] = "";
      $config['char_set'] = "utf8";
      $config['dbcollat'] = "utf8_general_ci";
  
      $DB2=$this-&gt;load-&gt;database($config);
  
      $DB2-&gt;db-&gt;select('first_name,last_name');
      $query = $DB2-&gt;db-&gt;get('person');
      print_r($query);
  
  }
  </code></pre>
  
  <p>its not working is there any other way?</p>