DatabaseServer; $database = (string) $applicationSettings->DatabaseName; $user = (string) $applicationSettings->DatabaseUser; $password = (string) $applicationSettings->DatabasePassword; try { $connection = new PDO("mysql:host={$host};dbname={$database}", $user, $password); } catch (PDOException | Exception $e) { echo "Unable to connect to the database.
"; echo "Error is: {$e->getMessage()}"; exit(); } // Retrieve the View Names. $views = array(); $directory = "."; if (is_dir($directory)) { if ($handle = opendir($directory)) { while (false !== ($filename = readdir($handle))) { if ($filename != "." && $filename != ".." && !is_dir("{$directory}/{$filename}")) { if (substr($filename, 0, 5) !== "view_") { continue; } $views[] = $filename; } } closedir($handle); } } if (count($views) === 0) { echo "No views found. Views not created."; exit(); } // Create the Views $created = 0; $not_created = 0; foreach ($views as $view) { if ((include "{$view}") != true) { echo "{$view} not found. View not created
."; continue; } $view = str_replace(".php", "", $view); $connection->exec("drop view if exists {$view}"); $connection->exec($SQL); if ($connection->errorCode() != 0) { $not_created++; echo "Error creating view {$view}:
"; echo "
";
        print_r($connection->errorInfo());
        echo "
"; } else { $created++; echo "{$view} was created.
"; } } echo "
{$created} Views were created. {$not_created} were not created due to errors."; ?>