tags:

views:

59

answers:

2

If I configure my CI application to use database for session handling, if a session userdata returns false, I can assume that the user's session has expired.

But what if the actual reason that it returned false was because the database connection was not established successfully?

A: 

CI throws

A Database Error Occurred
Unable to connect to your database server using the provided settings.

or something similar on connection failure

someGuy
That only happens if you have db_debut = TRUE in your database.php.
Phil Sturgeon
+1  A: 

By default CodeIgniter will fatal error if the database is loaded and cannot connect, but if you have:

$db['local']['db_debug'] = FALSE;

then it won't tell you. You can turn debugging off in general but still react to a failed load by doing this:

if ( $this->load->database() === FALSE )
{
   exit('THE END IS NIGH!');
}
Phil Sturgeon