• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL connection failure handling

#1
[eluser]Unknown[/eluser]
Hello all,

I've been struggling with a small mysql issue, though I see a couple of ways to solve this myself I figured I might as well put it out here.

Moving away from a classic "loose php script" website, we are building our new website on PyroCMS(2.1)/CodeIgniter .
Currently I'm running a website that connects to a second, external database to obtain some information of the status of a server.

However, it may occur that (for example during maintenance) this machine is offline for a short period.
Thus the second database connection might become unavailable.
Currerntly, when this occurs I'm confronted with this error:

Code:
Unable to connect to your database server using the provided settings.

Filename: /home/exwow/new/libraries/MX/Loader.php

Line Number: 94

My question, how can I circumvent this, so that the website simply carries on in case of failure to connect. Currently it forces this error. I see a way out of this by editing the core classes, but this issue does really not seem that special, there must be a accepted solution out there somewhere. (and serve cached content instead)

Additionally I'd like to alter the timeout for this second database connection to prevent it taking 30 seconds to load.

I'm using the CodeIgniter Database class.
Code:
$this->config->load('config');
$info = $this->config->item('db');
$this->db2 = $this->load->database($info['realm1'],TRUE);


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.