Example #1
0
<?php

/**
 * Created by IntelliJ IDEA.
 * User: Remco
* Date: 1-2-2016
* Time: 15:57
*/
include "include/config.php";
require "database/Database.php";
$db = new Database();
$db->connectDb();
Example #2
0
    // want to impose too many "are you sure?" questions
    // we will still not overwrite as we check tables don't exist before creating
    $action_required = 'tables';
} elseif ($db->getStatus() == -2) {
    // We can only create db if we are on mysql (in this version)
    if ($dbsettings['dbtype'] == 'mysql') {
        // Try creating database
        if (!$db->createDb($dbsettings['database'])) {
            // unable to create database - most likely permissions - hosted accounts may need to create
            // the database using the hosting cpanel etc.
            displayDbError("Unable to create new database " . $dbsettings['database'] . " <br />\nThis is normally due to insufficient permissions. If using a hosting account on a shared server you may need to use cpanel or ask your hosting provider for how to create a database<br />\nPlease read the install documentation for more details and then create the database manually before reloading this page.\n");
            exit(0);
        } else {
            $status_msg .= "\nNew database created " . $dbsettings['database'] . "<br />\n\n";
            // now connect to the new database
            if (!$db->connectDb($dbsettings['database'])) {
                // shouldn't get this as if we have permission to create the database we should be able to connect to it. Perhaps we have lost our network connection
                $error_msg = $db->getError();
                displayDbError("Unable to connect to the new database " . $dbsettings['database'] . " <br />\nError {$error_msg}.\n");
                exit(0);
            } else {
                $status_msg .= "\nConnected to the new database <br />\n\n";
                $action_required = 'tables';
            }
        }
    } else {
        $error_msg = $db->getError();
        displayDbError("Unable to connect to the database " . $error_msg . "\n<br />If not using mysql then you will need to create the database manually. Please read the install documenation for more details\n");
    }
} else {
    $error_msg = $db->getError();