[eluser]billmce[/eluser]
I've got a situation where I have to open a 2nd database outside the active records.
This database is outside of my control and has, on occassion, been inactivated.
I need to be able to trap when the connection is down .. so I can react accordingly.
Code:
// Connect to the database.
$dsn = $this->__connectDB1();
$DB1 = $this->load->database($dsn, TRUE);
// Get the general headings.
$query = $DB1->get('general');
.... stuff happens here ....
function __connectDB1()
{
/**
* Connect to outside database
*
*/
$dsn['hostname'] = $this->config->item('stats_host','company_stats');
$dsn['username'] = $this->config->item('stats_user','company_stats');
$dsn['password'] = $this->config->item('stats_pass','company_stats');
$dsn['database'] = $this->config->item('stats_db','company_stats');
$dsn['dbdriver'] = "mysql";
$dsn['dbprefix'] = "";
$dsn['pconnect'] = FALSE;
$dsn['db_debug'] = FALSE;
$dsn['cache_on'] = FALSE;
$dsn['cachedir'] = "";
$dsn['char_set'] = "utf8";
$dsn['dbcollat'] = "utf8_general_ci";
return $dsn;
}
How can I identify when the database is not available?
Thanks in advance.