Welcome Guest, Not a member yet? Register   Sign In
Testing database connections
#3

That makes sense. The following is working for me as far as I can tell. Anyone see any problems?
PHP Code:
    public function check_database()
    {
        
        
ini_set('display_errors''Off');
        
        
//  Load the database config file.
        
if(file_exists($file_path APPPATH.'config/database.php'))
        {
            include(
$file_path);
        }
        
        
$config $db[$active_group];
        
        
//  Check database connection if using mysqli driver
        
if( $config['dbdriver'] === 'mysqli' )
        {
            
$mysqli = new mysqli$config['hostname'] , $config['username'] , $config['password'] , $config['database'] );
            if( !
$mysqli->connect_error )
            {
                return 
true;
            }
            else{
                return 
false;
            }
        }
        else
        {
            return 
false;
        }
    } 
Reply


Messages In This Thread
Testing database connections - by BenHeadrick - 03-30-2015, 10:24 PM
RE: Testing database connections - by CroNiX - 03-31-2015, 06:55 AM
RE: Testing database connections - by BenHeadrick - 03-31-2015, 04:04 PM
RE: Testing database connections - by CroNiX - 04-01-2015, 07:14 AM
RE: Testing database connections - by silentium - 04-01-2015, 10:26 AM
RE: Testing database connections - by BenHeadrick - 04-03-2015, 07:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB