I would like to backup my read replica database (i.e. slave) with my main database, but this is a simple boolean I made:
$config['hostname'] = "myReadReplicaDatabase.com";
$db_obj=$CI->load->database($config, TRUE);
if(!$db_obj){
$config['hostname'] = "myMasterDatabase.com";
$db_obj=$CI->load->database($config, TRUE);
}
After completing my read replica database, I expected the boolean value to be evaluated like the FALSEscript, to use my main database then. Unfortunately, I got the following PHP error instead:
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
All I want is a connection to return true or false, does anyone know how to do this in Codeigniter?
source
share