title: You have specified an invalid database connection group in codeigniter
body: <p>So I tried to connect to multiple database in code igniter but it keeps displaying this error: "You have specified an invalid database connection group (siswa2) in your config/database.php file."</p>
  
  <p>What would the problem be?</p>
  
  <p>I made a little change on autoload:</p>
  
  <p>config/autoload.php</p>
  
  <pre><code>$autoload['libraries'] = array('database');
  </code></pre>
  
  <p>config/database.php - database config</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  
  $active_group = 'default';
  $query_builder = TRUE;
  
  $db['default'] = array(
      'dsn'   =&gt; '',
      'hostname' =&gt; 'localhost',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'database' =&gt; 'siswa1',
      'dbdriver' =&gt; 'mysqli',
      'dbprefix' =&gt; '',
      'pconnect' =&gt; FALSE,
      'db_debug' =&gt; (ENVIRONMENT !== 'production'),
      'cache_on' =&gt; FALSE,
      'cachedir' =&gt; '',
      'char_set' =&gt; 'utf8',
      'dbcollat' =&gt; 'utf8_general_ci',
      'swap_pre' =&gt; '',
      'encrypt' =&gt; FALSE,
      'compress' =&gt; FALSE,
      'stricton' =&gt; FALSE,
      'failover' =&gt; array(),
      'save_queries' =&gt; TRUE
  );
  
  $db2['siswa2'] = array(
      'dsn'   =&gt; '',
      'hostname' =&gt; 'localhost',
      'username' =&gt; 'root',
      'password' =&gt; '',
      'database' =&gt; 'siswa2',
      'dbdriver' =&gt; 'mysqli',
      'dbprefix' =&gt; '',
      'pconnect' =&gt; FALSE,
      'db_debug' =&gt; (ENVIRONMENT !== 'production'),
      'cache_on' =&gt; FALSE,
      'cachedir' =&gt; '',
      'char_set' =&gt; 'utf8',
      'dbcollat' =&gt; 'utf8_general_ci',
      'swap_pre' =&gt; '',
      'encrypt' =&gt; FALSE,
      'compress' =&gt; FALSE,
      'stricton' =&gt; FALSE,
      'failover' =&gt; array(),
      'save_queries' =&gt; TRUE
  );
  </code></pre>
  
  <p>models/Siswa_model.php</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class Siswa_model extends CI_Model {
  
   private $db2;
  
   public function __construct()
   {
    parent::__construct();
           $this-&gt;db2 = $this-&gt;load-&gt;database('siswa2', TRUE);
   }
  
   public function get_db()
   {
    return $this-&gt;db-&gt;get('siswa');
   }
   public function get_db2()
   {
    return $this-&gt;db2-&gt;get('siswa');
   }
  }
  </code></pre>
  
  <p>controllers/Siswa.php</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class Siswa extends CI_Controller {
  public function index(){
  
  // load siswa_model
  $this-&gt;load-&gt;model('siswa_model');
  
  // Database 1
  $data['data1'] = $this-&gt;siswa_model-&gt;get_db();
  
  // Database 2
  $data['data2'] = $this-&gt;siswa_model-&gt;get_db2();
  
  $this-&gt;load-&gt;view('siswa', $data);
  }
  }
  </code></pre>