/** * Check if the credentials given can be used to establish a * connection with the DB server */ public static function checkDatabaseConnection() { try { $db = new \PDO("mysql:dbname=" . self::$database['dbname'] . ";host=" . self::$database['host'] . ";port=" . self::$database['port'], self::$database['username'], self::$database['password'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)); self::$dbh = $db; $notable = false; $tables = array("options", "data"); // The Tables of Lobby foreach ($tables as $tableName) { $results = self::$dbh->prepare("SHOW TABLES LIKE ?"); $results->execute(array(self::$database['prefix'] . $tableName)); if (!$results || $results->rowCount() == 0) { $notable = true; } } if (!$notable) { /* There are database tables */ ser("Error", "Lobby Tables with prefix <b>" . self::$database['prefix'] . "</b> exists. Delete (DROP) those tables and <a href='install.php?step=2" . \H::csrf("g") . "'>try again.</a>"); return false; } } catch (\PDOException $Exception) { ser("Error", "Unable to connect. Make sure that the settings you entered are correct. <cl/><a href='install.php?step=2'>Try Again</a>"); return false; } }
public static function createSQLiteDB($loc) { try { self::$dbh = new \PDO("sqlite:{$loc}", "", "", array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)); return true; } catch (\PDOException $e) { self::$error = $e->getMessage(); self::log("Unable to make SQLite database : " . self::$error); return false; } }