title: Codeigniter/PHP check if can connect to database
body: <p>I'd like to backup my read replica(i.e., slave) database with my master database but this simple boolean I did failed:</p>
  
  <pre><code>$config['hostname'] = "myReadReplicaDatabase.com";
  //...$config['other_stuff']; other config stuff...
  $db_obj=$CI-&gt;load-&gt;database($config, TRUE);
  
  if(!$db_obj){
       $config['hostname'] = "myMasterDatabase.com";
       $db_obj=$CI-&gt;load-&gt;database($config, TRUE);
  }
  </code></pre>
  
  <p>After terminating my read replica database I expected the boolean to evaluate to <code>FALSE</code> and the script to then use my master database. Unfortunately, instead I got the following PHP error:</p>
  
  <pre><code>Unable to connect to your database server using the provided settings.
  Filename: core/Loader.php
  </code></pre>
  
  <p>All i want is for the connection to return true or false, does anyone know how to do this in Codeigniter?</p>