/** * Connect to the database * * @return bool false on failure / mysqli MySQLi object instance on success */ public function connect() { // Try and connect to the database if (!isset(self::$connection)) { // Load configuration as an array. Use the actual location of your configuration file $config = parse_ini_file('config.ini'); self::$connection = new mysqli('localhost', $config['username'], $config['password'], $config['dbname']); } // If connection was not successful, handle the error if (self::$connection === false) { // Handle error - notify administrator, log to a file, show an error screen, etc. return false; } return self::$connection; }